-
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.
track trigger runs on update (#3654)
* track trigger runs on update * cleanup track update trigger migration * trigger track trigger for all unlisted tracks
- Loading branch information
1 parent
5f0803f
commit 6401d59
Showing
3 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
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
49 changes: 49 additions & 0 deletions
49
discovery-provider/alembic/versions/5d3f95470222_track_trigger_update.py
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,49 @@ | ||
"""track trigger update | ||
Revision ID: 5d3f95470222 | ||
Revises: f1e86fba0357 | ||
Create Date: 2022-08-17 14:06:25.596816 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '5d3f95470222' | ||
down_revision = 'f1e86fba0357' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
def upgrade(): | ||
connection = op.get_bind() | ||
connection.execute(sa.text(''' | ||
begin; | ||
drop trigger if exists on_track on tracks; | ||
create trigger on_track | ||
after insert or update on tracks | ||
for each row execute procedure handle_track(); | ||
-- trigger trigger for unlisted tracks | ||
update tracks | ||
set is_unlisted=is_unlisted | ||
where is_current=true and is_unlisted=true; | ||
commit; | ||
''')) | ||
|
||
|
||
def downgrade(): | ||
connection = op.get_bind() | ||
connection.execute(sa.text(''' | ||
begin; | ||
drop trigger if exists on_track on tracks; | ||
create trigger on_track | ||
after insert or update on tracks | ||
for each row execute procedure handle_track(); | ||
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