Migrating build configs to the new schema

This commit is contained in:
Laszlo Fogas 2019-06-19 16:13:09 +02:00
parent 7420131019
commit 806249ec16
6 changed files with 51 additions and 0 deletions

View file

@ -168,6 +168,10 @@ var migrations = []struct {
name: "update-table-set-config-name",
stmt: updateTableSetConfigName,
},
{
name: "populate-build-config",
stmt: populateBuildConfig,
},
}
// Migrate performs the database migration. If the migration fails
@ -660,3 +664,12 @@ ALTER TABLE config ADD COLUMN config_name TEXT
var updateTableSetConfigName = `
UPDATE config SET config_name = "drone"
`
//
// 021_populate_build_config.sql
//
var populateBuildConfig = `
INSERT INTO build_config (config_id, build_id)
SELECT build_config_id, build_id FROM builds
`

View file

@ -0,0 +1,4 @@
-- name: populate-build-config
INSERT INTO build_config (config_id, build_id)
SELECT build_config_id, build_id FROM builds

View file

@ -168,6 +168,10 @@ var migrations = []struct {
name: "update-table-set-config-name",
stmt: updateTableSetConfigName,
},
{
name: "populate-build-config",
stmt: populateBuildConfig,
},
}
// Migrate performs the database migration. If the migration fails
@ -662,3 +666,12 @@ ALTER TABLE config ADD COLUMN config_name TEXT
var updateTableSetConfigName = `
UPDATE config SET config_name = 'drone'
`
//
// 021_populate_build_config.sql
//
var populateBuildConfig = `
INSERT INTO build_config (config_id, build_id)
SELECT build_config_id, build_id FROM builds
`

View file

@ -0,0 +1,4 @@
-- name: populate-build-config
INSERT INTO build_config (config_id, build_id)
SELECT build_config_id, build_id FROM builds

View file

@ -172,6 +172,10 @@ var migrations = []struct {
name: "update-table-set-config-name",
stmt: updateTableSetConfigName,
},
{
name: "populate-build-config",
stmt: populateBuildConfig,
},
}
// Migrate performs the database migration. If the migration fails
@ -661,3 +665,12 @@ ALTER TABLE config ADD COLUMN config_name TEXT
var updateTableSetConfigName = `
UPDATE config SET config_name = "drone"
`
//
// 021_populate_build_config.sql
//
var populateBuildConfig = `
INSERT INTO build_config (config_id, build_id)
SELECT build_config_id, build_id FROM builds
`

View file

@ -0,0 +1,4 @@
-- name: populate-build-config
INSERT INTO build_config (config_id, build_id)
SELECT build_config_id, build_id FROM builds