Skip to content

Commit

Permalink
Merge pull request #25 from FigureTechnologies/hyperschwartz/allow-dy…
Browse files Browse the repository at this point in the history
…namic-file-locations-based-on-sql-type

Bugfix: SQL Dialect Unique Files
  • Loading branch information
hyperschwartz authored Sep 26, 2022
2 parents 9e82c96 + d943ba7 commit c814c68
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ class DataConfig {

@Bean
fun flyway(dataSource: DataSource, databaseProperties: DatabaseProperties): Flyway = Flyway(
FluentConfiguration().dataSource(dataSource).baselineOnMigrate(databaseProperties.baselineOnMigrate).apply {
if (databaseProperties.type != "postgresql") {
// skip initial 1_0__Init_UUID migration for non-postgres dbs as this isn't supported for sqlite/memory
baselineVersion("1.0")
}
}
FluentConfiguration().dataSource(dataSource).baselineOnMigrate(databaseProperties.baselineOnMigrate)
// Dynamically set the location for migration files based on the database type, allowing for multiple
// dialects to specify their own migrations as necessary
.locations("db/migration/common", "db/migration/${databaseProperties.type}")
).apply {
if (databaseProperties.type != "postgresql") {
baseline()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ ALTER TABLE scope_permissions ADD COLUMN grant_id text;

CREATE INDEX IF NOT EXISTS scope_permissions_grant_id_idx ON scope_permissions(grant_id);

-- Remove old index that enforces unique on scope_address/grantee_address/granter_address
DROP INDEX IF EXISTS scope_permissions_scope_address_grantee_address_granter_address;

-- Ensures that there can be duplicate grants from granters to grantees on a scope address, as long as the duplicate
-- specifies a newly-unique grant id
CREATE UNIQUE INDEX IF NOT EXISTS scope_permissions_scope_adr_grantee_adr_granter_adr_grant_id_nn
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Remove old index that enforces unique on scope_address/grantee_address/granter_address in preparation for new index
-- in the v3_1 migration.
DROP INDEX IF EXISTS scope_permissions_scope_address_grantee_address_granter_address;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Remove old index that enforces unique on scope_address/grantee_address/granter_address in preparation for new index
-- in the v3_1 migration.
ALTER TABLE scope_permissions DROP CONSTRAINT scope_permissions_scope_address_grantee_address_granter_address;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Remove old index that enforces unique on scope_address/grantee_address/granter_address in preparation for new index
-- in the v3_1 migration.
DROP INDEX IF EXISTS scope_permissions_scope_address_grantee_address_granter_address;

0 comments on commit c814c68

Please sign in to comment.