diff --git a/migration/migration.go b/migration/migration.go index 500f593658..95ba77c1a5 100644 --- a/migration/migration.go +++ b/migration/migration.go @@ -456,6 +456,15 @@ func GetMigrations() Migrations { // Version 106 m = append(m, steps{ExecuteSQLFile("106-remove-link-category-concept.sql")}) + // Version 107 + m = append(m, steps{ExecuteSQLFile("107-number-sequences-table.sql")}) + + // Version 108 + m = append(m, steps{ExecuteSQLFile("108-number-column-for-area.sql")}) + + // Version 109 + m = append(m, steps{ExecuteSQLFile("109-number-column-for-iteration.sql")}) + // Version N // // In order to add an upgrade, simply append an array of MigrationFunc to the diff --git a/migration/migration_blackbox_test.go b/migration/migration_blackbox_test.go index 3d30ff6a7b..ec3309f43f 100644 --- a/migration/migration_blackbox_test.go +++ b/migration/migration_blackbox_test.go @@ -156,6 +156,9 @@ func TestMigrations(t *testing.T) { t.Run("TestMirgraion104", testMigration104IndexOnWIRevisionTable) t.Run("TestMirgraion105", testMigration105UpdateRootIterationAreaPathField) t.Run("TestMirgraion106", testMigration106RemoveLinkCategoryConcept) + t.Run("TestMirgraion107", testMigration107NumberSequencesTable) + t.Run("TestMirgraion108", testMigration108NumberColumnForArea) + t.Run("TestMirgraion109", testMigration109NumberColumnForIteration) // Perform the migration err = migration.Migrate(sqlDB, databaseName) @@ -1365,6 +1368,21 @@ func testMigration106RemoveLinkCategoryConcept(t *testing.T) { }) } +func testMigration107NumberSequencesTable(t *testing.T) { + migrateToVersion(t, sqlDB, migrations[:108], 108) + require.True(t, dialect.HasTable("number_sequences")) +} + +func testMigration108NumberColumnForArea(t *testing.T) { + migrateToVersion(t, sqlDB, migrations[:109], 109) + require.True(t, dialect.HasColumn("areas", "number")) +} + +func testMigration109NumberColumnForIteration(t *testing.T) { + migrateToVersion(t, sqlDB, migrations[:110], 110) + require.True(t, dialect.HasColumn("iterations", "number")) +} + // runSQLscript loads the given filename from the packaged SQL test files and // executes it on the given database. Golang text/template module is used // to handle all the optional arguments passed to the sql test files diff --git a/migration/sql-files/107-number-sequences-table.sql b/migration/sql-files/107-number-sequences-table.sql new file mode 100644 index 0000000000..cfee13f971 --- /dev/null +++ b/migration/sql-files/107-number-sequences-table.sql @@ -0,0 +1,7 @@ + -- Create the number_sequences table +CREATE TABLE number_sequences ( + space_id uuid REFERENCES spaces(id) ON DELETE CASCADE, + table_name text CHECK (trim(table_name::text) <> ''), + current_val INTEGER NOT NULL, + PRIMARY KEY (space_id, table_name) +); \ No newline at end of file diff --git a/migration/sql-files/108-number-column-for-area.sql b/migration/sql-files/108-number-column-for-area.sql new file mode 100644 index 0000000000..3315196049 --- /dev/null +++ b/migration/sql-files/108-number-column-for-area.sql @@ -0,0 +1 @@ +ALTER TABLE areas ADD COLUMN number INTEGER; \ No newline at end of file diff --git a/migration/sql-files/109-number-column-for-iteration.sql b/migration/sql-files/109-number-column-for-iteration.sql new file mode 100644 index 0000000000..bd66d0e34e --- /dev/null +++ b/migration/sql-files/109-number-column-for-iteration.sql @@ -0,0 +1 @@ +ALTER TABLE iterations ADD COLUMN number INTEGER; \ No newline at end of file