-
Notifications
You must be signed in to change notification settings - Fork 216
Unify flyway schemas and fix PostgreSQL v1_12_35 #2906
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
Open
avgustinmm
wants to merge
1
commit into
eclipse-hawkbit:master
Choose a base branch
from
boschglobal:unify_flyway_schemas
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+990
−935
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
.../hawkbit-repository-jpa-flyway/src/main/resources/db/migration/H2/V1_12_37__unify__H2.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| -- remove unnecessary / faulty default for a tenant's scope unique key | ||
| ALTER TABLE sp_target_type ALTER COLUMN type_key DROP DEFAULT; | ||
|
|
||
| -- remove unused column | ||
| ALTER TABLE sp_rollout DROP COLUMN group_theshold; |
35 changes: 35 additions & 0 deletions
35
...it-repository-jpa-flyway/src/main/resources/db/migration/MYSQL/V1_12_37__unify__MYSQL.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| -- fix NOT NULL disappeared in V1_12_12__change_length_of_controller_id_and_name___MYSQL.sql and V1_12_22__change_target_type_name_length___MYSQL.sql | ||
| UPDATE sp_software_module SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_software_module MODIFY name VARCHAR(128) NOT NULL; | ||
| UPDATE sp_software_module_type SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_software_module_type MODIFY name VARCHAR(128) NOT NULL; | ||
|
|
||
| UPDATE sp_distribution_set SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_distribution_set MODIFY name VARCHAR(128) NOT NULL; | ||
| UPDATE sp_distribution_set_type SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_distribution_set_type MODIFY name VARCHAR(128) NOT NULL; | ||
| UPDATE sp_distribution_set_tag SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_distribution_set_tag MODIFY name VARCHAR(128) NOT NULL; | ||
|
|
||
| UPDATE sp_target SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_target MODIFY name VARCHAR(128) NOT NULL; | ||
| UPDATE sp_target_type SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_target_type MODIFY name VARCHAR(128) NOT NULL; | ||
| UPDATE sp_target_tag SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_target_tag MODIFY name VARCHAR(128) NOT NULL; | ||
| UPDATE sp_target_filter_query SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_target_filter_query MODIFY name VARCHAR(128) NOT NULL; | ||
|
|
||
| UPDATE sp_rollout SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_rollout MODIFY name VARCHAR(128) NOT NULL; | ||
| UPDATE sp_rollout_group SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_rollout_group MODIFY name VARCHAR(128) NOT NULL; | ||
|
|
||
| UPDATE sp_target SET controller_id = '' WHERE controller_id IS NULL; | ||
| ALTER TABLE sp_target MODIFY controller_id VARCHAR(256) NOT NULL; | ||
|
|
||
| -- remove unnecessary / faulty default for a tenant's scope unique key | ||
| ALTER TABLE sp_target_type ALTER COLUMN type_key DROP DEFAULT; | ||
|
|
||
| -- remove unused column | ||
| ALTER TABLE sp_rollout DROP COLUMN group_theshold; |
2 changes: 1 addition & 1 deletion
2
...rc/main/resources/db/migration/POSTGRESQL/V1_12_35__sm_type_min_artifacts__POSTGRESQL.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| ALTER TABLE sp_software_module_type ADD COLUMN min_artifacts integer default 0 NOT NULL; | ||
| DROP INDEX sp_idx_distribution_set_01; | ||
| DROP INDEX sp_idx_distribution_set_01_sp_distribution_set; | ||
| CREATE INDEX sp_idx_distribution_set_01 ON sp_distribution_set USING BTREE (tenant, deleted); | ||
| ALTER TABLE sp_distribution_set DROP COLUMN complete; | ||
110 changes: 110 additions & 0 deletions
110
...ory-jpa-flyway/src/main/resources/db/migration/POSTGRESQL/V1_12_37__unify__POSTGRESQL.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| -- fix NOT NULL V1_12_15__baseline___POSTGRESQL.sql and V1_12_22__change_target_type_name_length___POSTGRESQL.sql | ||
| UPDATE sp_software_module SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_software_module ALTER COLUMN name SET NOT NULL; | ||
| UPDATE sp_software_module_type SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_software_module_type ALTER COLUMN name SET NOT NULL; | ||
|
|
||
| UPDATE sp_distribution_set SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_distribution_set ALTER COLUMN name SET NOT NULL; | ||
| UPDATE sp_distribution_set_type SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_distribution_set_type ALTER COLUMN name SET NOT NULL; | ||
| UPDATE sp_distribution_set_tag SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_distribution_set_tag ALTER COLUMN name SET NOT NULL; | ||
|
|
||
| UPDATE sp_target SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_target ALTER COLUMN name SET NOT NULL; | ||
| UPDATE sp_target_type SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_target_type ALTER COLUMN name SET NOT NULL; | ||
| UPDATE sp_target_tag SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_target_tag ALTER COLUMN name SET NOT NULL; | ||
| UPDATE sp_target_filter_query SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_target_filter_query ALTER COLUMN name SET NOT NULL; | ||
|
|
||
| UPDATE sp_rollout SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_rollout ALTER COLUMN name SET NOT NULL; | ||
| UPDATE sp_rollout_group SET name = '' WHERE name IS NULL; | ||
| ALTER TABLE sp_rollout_group ALTER COLUMN name SET NOT NULL; | ||
|
|
||
| UPDATE sp_target SET controller_id = '' WHERE controller_id IS NULL; | ||
| ALTER TABLE sp_target ALTER COLUMN controller_id SET NOT NULL; | ||
|
|
||
| -- fix sp_target_conf_status_new column order (to be MySQL and H2 schemes compatible) | ||
| BEGIN; | ||
|
|
||
| CREATE TABLE sp_target_conf_status_new ( | ||
| id BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
| target BIGINT NOT NULL, | ||
| initiator VARCHAR(64), | ||
| remark VARCHAR(512), | ||
| created_at BIGINT, | ||
| created_by VARCHAR(64), | ||
| last_modified_at BIGINT, | ||
| last_modified_by VARCHAR(64), | ||
| optlock_revision BIGINT, | ||
| tenant VARCHAR(40) NOT NULL, | ||
| PRIMARY KEY (id) | ||
| ); | ||
|
|
||
| INSERT INTO sp_target_conf_status_new | ||
| SELECT id, target, initiator, remark, created_at, created_by, last_modified_at, last_modified_by, optlock_revision, tenant | ||
| FROM sp_target_conf_status; | ||
| -- inserting with id hasn't / may haven't incremented the sequence | ||
| DO $$ | ||
| BEGIN | ||
| PERFORM setval('sp_target_conf_status_new_id_seq', (SELECT MAX(id) FROM sp_target_conf_status_new)); | ||
| END $$; | ||
|
|
||
| DROP TABLE sp_target_conf_status; | ||
| ALTER TABLE sp_target_conf_status_new RENAME TO sp_target_conf_status; | ||
|
|
||
| COMMIT; | ||
|
|
||
| DROP INDEX sp_idx_rollout_group_parent; | ||
| ALTER TABLE sp_target_conf_status | ||
| ADD CONSTRAINT fk_target_conf_status_target FOREIGN KEY (target) REFERENCES sp_target (id) ON DELETE CASCADE; | ||
| ALTER TABLE sp_target_type_ds_type | ||
| ADD CONSTRAINT pk_sp_target_type_ds_type PRIMARY KEY (target_type, distribution_set_type); | ||
|
|
||
| -- remove unnecessary / faulty default for a tenant's scope unique key | ||
| ALTER TABLE sp_target_type ALTER COLUMN type_key DROP DEFAULT; | ||
|
|
||
| -- remove unused column | ||
| ALTER TABLE sp_rollout DROP COLUMN group_theshold; | ||
|
|
||
| -- -- unify index names -- | ||
| -- sp_distribution_set_tag table indexes | ||
| ALTER INDEX sp_idx_distribution_set_tag_01_sp_distributionset_tag RENAME TO sp_idx_distribution_set_tag_01; | ||
| ALTER INDEX sp_idx_distribution_set_tag_prim_sp_distributionset_tag RENAME TO sp_idx_distribution_set_tag_prim; | ||
| -- sp_distribution_set_type table indexes | ||
| ALTER INDEX sp_idx_distribution_set_type_prim_sp_distribution_set_type RENAME TO sp_idx_distribution_set_type_prim; | ||
| ALTER INDEX sp_idx_distribution_set_type_01_sp_distribution_set_type RENAME TO sp_idx_distribution_set_type_01; | ||
| -- sp_software_module_type table indexes | ||
| ALTER INDEX sp_idx_software_module_type_prim_sp_software_module_type RENAME TO sp_idx_software_module_type_prim; | ||
| ALTER INDEX sp_idx_software_module_type_01_sp_software_module_type RENAME TO sp_idx_software_module_type_01; | ||
| -- sp_target_tag table indexes | ||
| ALTER INDEX sp_idx_target_tag_prim_sp_target_tag RENAME TO sp_idx_target_tag_prim; | ||
| ALTER INDEX sp_idx_target_tag_01_sp_target_tag RENAME TO sp_idx_target_tag_01; | ||
| -- sp_distribution_set table indexes | ||
| ALTER INDEX sp_idx_distribution_set_prim_sp_distribution_set RENAME TO sp_idx_distribution_set_prim; | ||
| -- sp_tenant table indexes | ||
| ALTER INDEX sp_idx_tenant_prim_sp_tenant RENAME TO sp_idx_tenant_prim; | ||
| -- sp_rollout table indexes | ||
| ALTER INDEX uk_rollout_sp_rollout RENAME TO uk_rollout; | ||
| -- sp_target table indexes | ||
| ALTER INDEX uk_target RENAME TO uk_target_controller_id; | ||
| ALTER INDEX sp_idx_target_01_sp_target RENAME TO sp_idx_target_01; | ||
| ALTER INDEX sp_idx_target_03_sp_target RENAME TO sp_idx_target_03; | ||
| ALTER INDEX sp_idx_target_04_sp_target RENAME TO sp_idx_target_04; | ||
| ALTER INDEX sp_idx_target_prim_sp_target RENAME TO sp_idx_target_prim; | ||
| -- sp_artifact table indexes | ||
| ALTER INDEX sp_idx_artifact_prim_sp_artifact RENAME TO sp_idx_artifact_prim; | ||
| ALTER INDEX sp_idx_artifact_01_sp_artifact RENAME TO sp_idx_artifact_01; | ||
| ALTER INDEX sp_idx_artifact_02_sp_artifact RENAME TO sp_idx_artifact_02; | ||
| -- sp_action table indexes | ||
| ALTER INDEX sp_idx_action_prim_sp_action RENAME TO sp_idx_action_prim; | ||
| ALTER INDEX sp_idx_action_01_sp_action RENAME TO sp_idx_action_01; | ||
| ALTER INDEX sp_idx_action_02_sp_action RENAME TO sp_idx_action_02; | ||
| ALTER INDEX sp_idx_action_external_ref_sp_action RENAME TO sp_idx_action_external_ref; | ||
| -- sp_action_status table indexes | ||
| ALTER INDEX sp_idx_action_status_prim_sp_action_status RENAME TO sp_idx_action_status_prim; | ||
| ALTER INDEX sp_idx_action_status_02_sp_action_status RENAME TO sp_idx_action_status_02; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this edits intermediate migration - is that even ok ?
what happens if already processed but now it is with different checksum ?