diff --git a/service/gradle.properties b/service/gradle.properties index 9fc9ef772c1..b2bbb833bf2 100644 --- a/service/gradle.properties +++ b/service/gradle.properties @@ -11,6 +11,7 @@ flyway.password=flyway # Runtime properties passed to schema migrations (to avoid hardcoded role names) flyway.placeholders.application_user=evaka_application_local flyway.placeholders.migration_user=evaka_migration_local +flyway.cleanDisabled=false # URL for main DB flyway.url=jdbc:postgresql://localhost:5432/evaka_local diff --git a/service/src/main/resources/db/migration/V433__application_primary_preferred_unit.sql b/service/src/main/resources/db/migration/V433__application_primary_preferred_unit.sql new file mode 100644 index 00000000000..582ad0c8bc1 --- /dev/null +++ b/service/src/main/resources/db/migration/V433__application_primary_preferred_unit.sql @@ -0,0 +1,5 @@ +ALTER TABLE application ADD COLUMN primary_preferred_unit uuid + GENERATED ALWAYS AS ((document -> 'apply' -> 'preferredUnits' ->> 0)::uuid) STORED + CONSTRAINT fk$primary_preferred_unit REFERENCES daycare (id); + +CREATE INDEX idx$application_primary_unit_status ON application (primary_preferred_unit); diff --git a/service/src/main/resources/migrations.txt b/service/src/main/resources/migrations.txt index cb19dcacfd2..7fab12f99b3 100644 --- a/service/src/main/resources/migrations.txt +++ b/service/src/main/resources/migrations.txt @@ -429,3 +429,4 @@ V429__placement_created_updated_not_null.sql V430__child_attendance_timestamps.sql V431__child_attendance_range_index.sql V432__document_template_placement_types.sql +V433__application_primary_preferred_unit.sql