change cmd_migrate table name to prevent conflict

This commit is contained in:
sawka 2023-07-30 18:46:57 -07:00
parent 36a20a14c4
commit 483bcbe338
3 changed files with 9 additions and 9 deletions

View File

@ -26,16 +26,14 @@ CREATE TABLE cmd_new (
PRIMARY KEY (screenid, lineid)
);
DROP TABLE IF EXISTS cmd_migrate;
CREATE TABLE cmd_migrate (
CREATE TABLE cmd_migrate20 (
screenid varchar(36) NOT NULL,
lineid varchar(36) NOT NULL,
cmdid varchar(36) NOT NULL,
PRIMARY KEY (screenid, lineid)
);
INSERT INTO cmd_migrate
INSERT INTO cmd_migrate20
SELECT screenid, lineid, cmdid
FROM line;

View File

@ -104,7 +104,7 @@ func MigrateUp(targetVersion uint) error {
for newVersion := curVersion + 1; newVersion <= targetVersion; newVersion++ {
err = MigrateUpStep(m, newVersion)
if err != nil {
return fmt.Errorf("during migration v%d: %w", err, newVersion)
return fmt.Errorf("during migration v%d: %w", newVersion, err)
}
}
log.Printf("[db] migration done, new version = %d\n", targetVersion)

View File

@ -36,11 +36,13 @@ func RunMigration20() error {
startTime := time.Now()
var migrations []cmdMigration20Type
txErr := WithTx(ctx, func(tx *TxWrap) error {
tx.Select(&migrations, `SELECT * FROM cmd_migrate`)
m := tx.SelectMaps(`SELECT * FROM cmd_migrate20`)
fmt.Printf("got maps: %#v\n", m)
tx.Select(&migrations, `SELECT * FROM cmd_migrate20`)
return nil
})
if txErr != nil {
return fmt.Errorf("trying to get cmd migrations: %w", txErr)
return fmt.Errorf("trying to get cmd20 migrations: %w", txErr)
}
log.Printf("[db] got %d cmd-line migrations\n", len(migrations))
for len(migrations) > 0 {
@ -75,7 +77,7 @@ func processMigration20Chunk(ctx context.Context, mchunk []cmdMigration20Type) e
}
txErr := WithTx(ctx, func(tx *TxWrap) error {
for _, mig := range mchunk {
query := `DELETE FROM cmd_migrate WHERE cmdid = ?`
query := `DELETE FROM cmd_migrate20 WHERE cmdid = ?`
tx.Exec(query, mig.CmdId)
}
return nil
@ -95,7 +97,7 @@ func RunMigration13() error {
return nil
})
if txErr != nil {
return fmt.Errorf("trying to get cmd migrations: %w", txErr)
return fmt.Errorf("trying to get cmd13 migrations: %w", txErr)
}
log.Printf("[db] got %d cmd-screen migrations\n", len(migrations))
for len(migrations) > 0 {