griffio / sqldelight-postgres-01

sqldelight 2.1.x postgresql flywaydb example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SqlDelight 2.1.x Postgresql migrations with Flyway

see https://github.com/griffio/sqldelight-postgres-02 for Liquibase migrations

https://github.com/cashapp/sqldelight

Some examples of newer postgresql support in sqldelight SNAPSHOT builds 2.1.x

Migrations performed

  • create sequence
  • alter sequence
  • add constraint foreign key
  • set default -
  • set not null
  • drop not null
  • drop column
  • rename column -
  • rename table
  • add check constraint
  • drop identity
  • alter identity

To find bugs/issues that need to be fixed/implemented

Issues

  • rename column - error with validation
  • alter table ... alter column ... drop identity - support but need fixing refers to old column if column was renamed
  • alter table ... alter column ... set default - compilation error must be specified in insert statement
  • sqm files must not have post-fix numbers e.g. V1_create_test_1.sqm as this breaks the ordering

Not supported

  • alter/drop sequence
  • alter table ... add constraint primary key ... (doesn't update data class property to non-nullable type)
  • add constraint check, foreign key valid and not valid clauses
  • alter column col_name add generated { always | by default } as identity { ( seq_option ) }
  • alter column column_name { set generated { always | by default } | set sequence_option | restart [ [ with ] restart ] }

Bugs

  • data class import missing in generated queries source when using star INSERT INTO City (city_name) VALUES (?) RETURNING *;
  • allows unknown columns with alter table ... alter column - must show compiler error No column found to alter with name <unknown name>
  • compiler error when functions are used as DEFAULT column values

./gradlew build
./gradlew flywayMigrate

Flyway db migrations https://documentation.red-gate.com/fd/gradle-task-184127407.html

About

sqldelight 2.1.x postgresql flywaydb example


Languages

Language:Kotlin 100.0%