-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from python-discord/jb3/sqlalchemy-2
SQLAlchemy 2
- Loading branch information
Showing
37 changed files
with
827 additions
and
693 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
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
65 changes: 65 additions & 0 deletions
65
alembic/versions/03655ce2097b_new_not_null_constraints_on_messages_.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,65 @@ | ||
""" | ||
New NOT NULL constraints on messages and users table. | ||
Revision ID: 03655ce2097b | ||
Revises: 563a15b2a76e | ||
Create Date: 2023-09-04 20:17:03.543328 | ||
""" | ||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "03655ce2097b" | ||
down_revision = "563a15b2a76e" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
"""Apply the current migration.""" | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.alter_column("messages", "channel_id", | ||
existing_type=sa.VARCHAR(), | ||
nullable=False) | ||
op.alter_column("messages", "author_id", | ||
existing_type=sa.VARCHAR(), | ||
nullable=False) | ||
op.alter_column("messages", "is_deleted", | ||
existing_type=sa.BOOLEAN(), | ||
nullable=False) | ||
op.alter_column("users", "bot", | ||
existing_type=sa.BOOLEAN(), | ||
nullable=False) | ||
op.alter_column("users", "in_guild", | ||
existing_type=sa.BOOLEAN(), | ||
nullable=False) | ||
op.alter_column("users", "pending", | ||
existing_type=sa.BOOLEAN(), | ||
nullable=False) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
"""Revert the current migration.""" | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.alter_column("users", "pending", | ||
existing_type=sa.BOOLEAN(), | ||
nullable=True) | ||
op.alter_column("users", "in_guild", | ||
existing_type=sa.BOOLEAN(), | ||
nullable=True) | ||
op.alter_column("users", "bot", | ||
existing_type=sa.BOOLEAN(), | ||
nullable=True) | ||
op.alter_column("messages", "is_deleted", | ||
existing_type=sa.BOOLEAN(), | ||
nullable=True) | ||
op.alter_column("messages", "author_id", | ||
existing_type=sa.VARCHAR(), | ||
nullable=True) | ||
op.alter_column("messages", "channel_id", | ||
existing_type=sa.VARCHAR(), | ||
nullable=True) | ||
# ### end Alembic commands ### |
19 changes: 11 additions & 8 deletions
19
alembic/versions/25f3b8fb9961_add_pending_column_to_user.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 |
---|---|---|
@@ -1,28 +1,31 @@ | ||
"""add pending column to user | ||
""" | ||
add pending column to user. | ||
Revision ID: 25f3b8fb9961 | ||
Revises: a259ab5efcec | ||
Create Date: 2020-12-21 17:42:04.566930 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '25f3b8fb9961' | ||
down_revision = 'a259ab5efcec' | ||
revision = "25f3b8fb9961" | ||
down_revision = "a259ab5efcec" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
def upgrade() -> None: | ||
"""Apply the current migration.""" | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column('users', sa.Column('pending', sa.Boolean(), nullable=True)) | ||
op.add_column("users", sa.Column("pending", sa.Boolean(), nullable=True)) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
def downgrade() -> None: | ||
"""Revert the current migration.""" | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column('users', 'pending') | ||
op.drop_column("users", "pending") | ||
# ### end Alembic commands ### |
81 changes: 42 additions & 39 deletions
81
alembic/versions/2743389eb63e_add_all_tables_with_string_keys.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 |
---|---|---|
@@ -1,63 +1,66 @@ | ||
"""add all tables with string keys | ||
""" | ||
add all tables with string keys. | ||
Revision ID: 2743389eb63e | ||
Revises: 2e383ecae493 | ||
Create Date: 2020-08-25 16:35:38.833315 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '2743389eb63e' | ||
down_revision = '2e383ecae493' | ||
revision = "2743389eb63e" | ||
down_revision = "2e383ecae493" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
def upgrade() -> None: | ||
"""Apply the current migration.""" | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('categories', | ||
sa.Column('id', sa.String(), nullable=False), | ||
sa.Column('name', sa.String(), nullable=False), | ||
sa.PrimaryKeyConstraint('id') | ||
op.create_table("categories", | ||
sa.Column("id", sa.String(), nullable=False), | ||
sa.Column("name", sa.String(), nullable=False), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table('users', | ||
sa.Column('id', sa.String(), nullable=False), | ||
sa.Column('name', sa.String(), nullable=False), | ||
sa.Column('avatar_hash', sa.String(), nullable=True), | ||
sa.Column('joined_at', sa.DateTime(), nullable=False), | ||
sa.Column('created_at', sa.DateTime(), nullable=False), | ||
sa.Column('is_staff', sa.Boolean(), nullable=False), | ||
sa.Column('opt_out', sa.Boolean(), nullable=True), | ||
sa.Column('bot', sa.Boolean(), nullable=True), | ||
sa.PrimaryKeyConstraint('id') | ||
op.create_table("users", | ||
sa.Column("id", sa.String(), nullable=False), | ||
sa.Column("name", sa.String(), nullable=False), | ||
sa.Column("avatar_hash", sa.String(), nullable=True), | ||
sa.Column("joined_at", sa.DateTime(), nullable=False), | ||
sa.Column("created_at", sa.DateTime(), nullable=False), | ||
sa.Column("is_staff", sa.Boolean(), nullable=False), | ||
sa.Column("opt_out", sa.Boolean(), nullable=True), | ||
sa.Column("bot", sa.Boolean(), nullable=True), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table('channels', | ||
sa.Column('id', sa.String(), nullable=False), | ||
sa.Column('name', sa.String(), nullable=False), | ||
sa.Column('category_id', sa.String(), nullable=True), | ||
sa.Column('is_staff', sa.Boolean(), nullable=False), | ||
sa.ForeignKeyConstraint(['category_id'], ['categories.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
op.create_table("channels", | ||
sa.Column("id", sa.String(), nullable=False), | ||
sa.Column("name", sa.String(), nullable=False), | ||
sa.Column("category_id", sa.String(), nullable=True), | ||
sa.Column("is_staff", sa.Boolean(), nullable=False), | ||
sa.ForeignKeyConstraint(["category_id"], ["categories.id"] ), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table('messages', | ||
sa.Column('id', sa.String(), nullable=False), | ||
sa.Column('channel_id', sa.String(), nullable=True), | ||
sa.Column('author_id', sa.String(), nullable=True), | ||
sa.Column('created_at', sa.DateTime(), nullable=True), | ||
sa.ForeignKeyConstraint(['author_id'], ['users.id'], ondelete='CASCADE'), | ||
sa.ForeignKeyConstraint(['channel_id'], ['channels.id'], ondelete='CASCADE'), | ||
sa.PrimaryKeyConstraint('id') | ||
op.create_table("messages", | ||
sa.Column("id", sa.String(), nullable=False), | ||
sa.Column("channel_id", sa.String(), nullable=True), | ||
sa.Column("author_id", sa.String(), nullable=True), | ||
sa.Column("created_at", sa.DateTime(), nullable=True), | ||
sa.ForeignKeyConstraint(["author_id"], ["users.id"], ondelete="CASCADE"), | ||
sa.ForeignKeyConstraint(["channel_id"], ["channels.id"], ondelete="CASCADE"), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
def downgrade() -> None: | ||
"""Revert the current migration.""" | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('messages') | ||
op.drop_table('channels') | ||
op.drop_table('users') | ||
op.drop_table('categories') | ||
op.drop_table("messages") | ||
op.drop_table("channels") | ||
op.drop_table("users") | ||
op.drop_table("categories") | ||
# ### end Alembic commands ### |
25 changes: 13 additions & 12 deletions
25
alembic/versions/2e383ecae493_remove_all_tables_for_conversion_to_.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 |
---|---|---|
@@ -1,27 +1,28 @@ | ||
"""remove all tables for conversion to string keys | ||
""" | ||
remove all tables for conversion to string keys. | ||
Revision ID: 2e383ecae493 | ||
Revises: b1fdfe71fcb7 | ||
Create Date: 2020-08-25 16:31:05.025135 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '2e383ecae493' | ||
down_revision = 'b1fdfe71fcb7' | ||
revision = "2e383ecae493" | ||
down_revision = "b1fdfe71fcb7" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.drop_table('messages') | ||
op.drop_table('users') | ||
op.drop_table('channels') | ||
op.drop_table('categories') | ||
def upgrade() -> None: | ||
"""Apply the current migration.""" | ||
op.drop_table("messages") | ||
op.drop_table("users") | ||
op.drop_table("channels") | ||
op.drop_table("categories") | ||
|
||
|
||
def downgrade(): | ||
pass | ||
def downgrade() -> None: | ||
"""Revert the current migration.""" |
Oops, something went wrong.