-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
295 additions
and
144 deletions.
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
92 changes: 92 additions & 0 deletions
92
discovery-provider/alembic/versions/2cfd17a60647_solana_slot_follows.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,92 @@ | ||
"""solana slot follows | ||
Revision ID: 2cfd17a60647 | ||
Revises: a9215207bb7c | ||
Create Date: 2022-04-10 20:18:38.443308 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "2cfd17a60647" | ||
down_revision = "a9215207bb7c" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
connection = op.get_bind() | ||
connection.execute( | ||
""" | ||
begin; | ||
ALTER TABLE ursm_content_nodes DROP CONSTRAINT IF EXISTS ursm_content_nodes_pkey; | ||
UPDATE ursm_content_nodes | ||
SET txhash = ('unset_' || substr(md5(random()::text), 0, 10)) | ||
WHERE txhash=''; | ||
ALTER TABLE ursm_content_nodes ADD PRIMARY KEY (is_current, cnode_sp_id, txhash); | ||
ALTER TABLE ursm_content_nodes ADD COLUMN IF NOT EXISTS slot INTEGER; | ||
-- Drop NOT NULL Constraint on POA blockhash and tx hash columns | ||
ALTER TABLE ursm_content_nodes ALTER COLUMN blockhash DROP NOT NULL; | ||
ALTER TABLE ursm_content_nodes ALTER COLUMN blocknumber DROP NOT NULL; | ||
ALTER TABLE follows DROP CONSTRAINT IF EXISTS follows_pkey; | ||
UPDATE follows | ||
SET txhash = ('unset_' || substr(md5(random()::text), 0, 10)) | ||
WHERE txhash=''; | ||
ALTER TABLE follows ADD PRIMARY KEY (is_current, follower_user_id, followee_user_id, txhash); | ||
ALTER TABLE follows ADD COLUMN IF NOT EXISTS slot INTEGER; | ||
-- Drop NOT NULL Constraint on POA blockhash and tx hash columns | ||
ALTER TABLE follows ALTER COLUMN blockhash DROP NOT NULL; | ||
ALTER TABLE follows ALTER COLUMN blocknumber DROP NOT NULL; | ||
-- Drop NOT NULL Constraint on POA blockhash and tx hash columns | ||
ALTER TABLE user_events ADD COLUMN IF NOT EXISTS slot INTEGER; | ||
ALTER TABLE user_events ALTER COLUMN blockhash DROP NOT NULL; | ||
ALTER TABLE user_events ALTER COLUMN blocknumber DROP NOT NULL; | ||
commit; | ||
""" | ||
) | ||
|
||
|
||
def downgrade(): | ||
connection = op.get_bind() | ||
connection.execute( | ||
""" | ||
begin; | ||
ALTER TABLE ursm_content_nodes DROP CONSTRAINT IF EXISTS ursm_content_nodes_pkey; | ||
ALTER TABLE ursm_content_nodes ADD PRIMARY KEY (is_current, cnode_sp_id, blockhash, txhash); | ||
ALTER TABLE ursm_content_nodes DROP COLUMN IF EXISTS slot; | ||
-- Add NOT NULL Constraint on POA blockhash and tx hash columns | ||
DELETE FROM ursm_content_nodes where blockhash IS NULL or blocknumber IS NULL; | ||
ALTER TABLE ursm_content_nodes ALTER COLUMN blockhash SET NOT NULL; | ||
ALTER TABLE ursm_content_nodes ALTER COLUMN blocknumber SET NOT NULL; | ||
ALTER TABLE follows DROP CONSTRAINT IF EXISTS follows_pkey; | ||
ALTER TABLE follows ADD PRIMARY KEY (is_current, follower_user_id, followee_user_id, blockhash, txhash); | ||
ALTER TABLE follows DROP COLUMN IF EXISTS slot; | ||
-- Add NOT NULL Constraint on POA blockhash and tx hash columns | ||
ALTER TABLE follows ALTER COLUMN blockhash SET NOT NULL; | ||
ALTER TABLE follows ALTER COLUMN blocknumber SET NOT NULL; | ||
-- Drop NOT NULL Constraint on POA blockhash and tx hash columns | ||
ALTER TABLE user_events DROP COLUMN IF EXISTS slot; | ||
ALTER TABLE user_events ALTER COLUMN blockhash SET NOT NULL; | ||
ALTER TABLE user_events ALTER COLUMN blocknumber SET NOT NULL; | ||
commit; | ||
""" | ||
) |
58 changes: 58 additions & 0 deletions
58
discovery-provider/alembic/versions/2dbbc9c484e3_solana_slot_tracks.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,58 @@ | ||
"""solana slot tracks | ||
Revision ID: 2dbbc9c484e3 | ||
Revises: 11060779bb3a | ||
Create Date: 2022-04-10 20:12:18.383547 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "2dbbc9c484e3" | ||
down_revision = "11060779bb3a" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
connection = op.get_bind() | ||
connection.execute( | ||
""" | ||
begin; | ||
ALTER TABLE tracks DROP CONSTRAINT IF EXISTS tracks_pkey; | ||
UPDATE tracks | ||
SET txhash = ('unset_' || substr(md5(random()::text), 0, 10)) | ||
WHERE txhash=''; | ||
ALTER TABLE tracks ADD PRIMARY KEY (is_current, track_id, txhash); | ||
ALTER TABLE tracks ADD COLUMN IF NOT EXISTS slot INTEGER; | ||
-- Drop NOT NULL Constraint on POA blockhash and tx hash columns | ||
ALTER TABLE tracks ALTER COLUMN blockhash DROP NOT NULL; | ||
ALTER TABLE tracks ALTER COLUMN blocknumber DROP NOT NULL; | ||
commit; | ||
""" | ||
) | ||
|
||
|
||
def downgrade(): | ||
connection = op.get_bind() | ||
connection.execute( | ||
""" | ||
begin; | ||
ALTER TABLE tracks DROP CONSTRAINT IF EXISTS tracks_pkey; | ||
ALTER TABLE tracks ADD PRIMARY KEY (is_current, track_id, blockhash, txhash); | ||
ALTER TABLE tracks DROP COLUMN IF EXISTS slot; | ||
-- Add NOT NULL Constraint on POA blockhash and tx hash columns | ||
DELETE FROM tracks where blockhash IS NULL or blocknumber IS NULL; | ||
ALTER TABLE tracks ALTER COLUMN blockhash SET NOT NULL; | ||
ALTER TABLE tracks ALTER COLUMN blocknumber SET NOT NULL; | ||
commit; | ||
""" | ||
) |
60 changes: 60 additions & 0 deletions
60
discovery-provider/alembic/versions/3a3f2c9f5320_solana_slot_playlists.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,60 @@ | ||
"""solana slot social | ||
Revision ID: 3a3f2c9f5320 | ||
Revises: 2dbbc9c484e3 | ||
Create Date: 2022-04-10 20:13:10.421757 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "3a3f2c9f5320" | ||
down_revision = "2dbbc9c484e3" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
connection = op.get_bind() | ||
connection.execute( | ||
""" | ||
begin; | ||
ALTER TABLE playlists DROP CONSTRAINT IF EXISTS playlists_pkey; | ||
UPDATE playlists | ||
SET txhash = ('unset_' || substr(md5(random()::text), 0, 10)) | ||
WHERE txhash=''; | ||
ALTER TABLE playlists ADD PRIMARY KEY (is_current, playlist_id, txhash); | ||
ALTER TABLE playlists ADD COLUMN IF NOT EXISTS slot INTEGER; | ||
-- Drop NOT NULL Constraint on POA blockhash and tx hash columns | ||
ALTER TABLE playlists ALTER COLUMN blockhash DROP NOT NULL; | ||
ALTER TABLE playlists ALTER COLUMN blocknumber DROP NOT NULL; | ||
commit; | ||
""" | ||
) | ||
|
||
|
||
def downgrade(): | ||
connection = op.get_bind() | ||
connection.execute( | ||
""" | ||
begin; | ||
ALTER TABLE playlists DROP CONSTRAINT IF EXISTS playlists_pkey; | ||
ALTER TABLE playlists ADD PRIMARY KEY (is_current, playlist_id, playlist_owner_id, blockhash, txhash); | ||
ALTER TABLE playlists DROP COLUMN IF EXISTS slot; | ||
-- Add NOT NULL Constraint on POA blockhash and tx hash columns | ||
DELETE FROM playlists where blockhash IS NULL or blocknumber IS NULL; | ||
ALTER TABLE playlists ALTER COLUMN blockhash SET NOT NULL; | ||
ALTER TABLE playlists ALTER COLUMN blocknumber SET NOT NULL; | ||
commit; | ||
""" | ||
) |
Oops, something went wrong.