-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate release_date from string to date (#6655)
- Loading branch information
Showing
13 changed files
with
107 additions
and
91 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
packages/discovery-provider/ddl/migrations/0039_migrate_date.sql
This file contains 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,22 @@ | ||
-- migrate release_date to a timestamp | ||
begin; | ||
lock table tracks in access exclusive mode; | ||
|
||
alter table tracks disable trigger on_track; | ||
alter table tracks disable trigger trg_tracks; | ||
|
||
alter table tracks add column release_date_temp timestamp; | ||
|
||
update tracks set release_date_temp = to_timestamp(release_date, 'YYYY-MM-DD"T"HH24:MI:SS.US')::timestamp | ||
where release_date like '%Z'; | ||
|
||
update tracks set release_date_temp = to_timestamp(substring(release_date from 1 for 20), 'Dy Mon DD YYYY HH24:MI:SS') | ||
where release_date like '%GMT%' and length(release_date) > 22; | ||
|
||
alter table tracks drop column release_date; | ||
|
||
alter table tracks rename column release_date_temp to release_date; | ||
|
||
alter table tracks enable trigger on_track; | ||
alter table tracks enable trigger trg_tracks; | ||
commit; |
This file contains 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 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 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 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 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 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 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 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 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 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
Oops, something went wrong.