Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Base Migration to Support Multiple Ordering Providers #8178

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 86 additions & 1 deletion backend/src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5642,4 +5642,89 @@ databaseChangeLog:
rollback:
- dropColumn:
tableName: test_order
columnName: timer_started_at
columnName: timer_started_at

- changeSet:
id: create-facility_providers-table
author: bobby@skylight.digital
changes:
- tagDatabase:
tag: add-facility-providers-table
- createTable:
tableName: facility_providers
remarks: Many-to-many table for multiple providers configuration at a facility.
columns:
- column:
name: facility_id
type: uuid
constraints:
nullable: false
foreignKeyName: fk__facility_providers__facility
references: facility
- column:
name: provider_id
type: uuid
constraints:
nullable: false
foreignKeyName: fk__facility_providers__provider
references: provider
rollback:
- dropTable:
tableName: facility_providers

- changeSet:
id: add-default-provider
author: bobby@skylight.digital
changes:
- tagDatabase:
tag: add-default-provider-col
- addColumn:
tableName: facility
columns:
- column:
name: default_ordering_provider_id
remarks: The default ordering provider for tests at this facility.
type: uuid
constraints:
foreignKeyName: fk__facility__default_ordering_provider
references: provider(internal_id)
rollback:
sql: |
ALTER TABLE ${database.defaultSchemaName}.facility DROP COLUMN default_ordering_provider_id;

- changeSet:
id: populate-facility-providers-table
author: bobby@skylight.digital
changes:
- tagDatabase:
tag: populate-facility-providers-table
- sql: |
INSERT INTO ${database.defaultSchemaName}.facility_providers (
facility_id,
provider_id
)
SELECT
internal_id,
ordering_provider_id
FROM ${database.defaultSchemaName}.facility;
rollback:
sql: |
TRUNCATE TABLE ${database.defaultSchemaName}.facility_providers;

- changeSet:
id: populate-default-provider-column
author: bobby@skylight.digital
changes:
- tagDatabase:
tag: populate-default-provider-column
- sql: |
UPDATE ${database.defaultSchemaName}.facility
SET
default_ordering_provider_id = facility.ordering_provider_id
WHERE facility.default_ordering_provider_id is NULL;
rollback:
sql: |
UPDATE ${database.defaultSchemaName}.facility
SET
default_ordering_provider_id = NULL
WHERE facility.default_ordering_provider_id is NOT NULL;
Loading