diff --git a/alembic.ini b/alembic.ini index 3f22c7d..f0e7f77 100644 --- a/alembic.ini +++ b/alembic.ini @@ -9,6 +9,7 @@ script_location = alembic # see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file # for all available tokens # file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s +file_template = %%(epoch)s_%%(slug)s # sys.path path, will be prepended to sys.path if present. # defaults to the current working directory. diff --git a/alembic/versions/b39613fd7327_init.py b/alembic/versions/1709998348_init.py similarity index 100% rename from alembic/versions/b39613fd7327_init.py rename to alembic/versions/1709998348_init.py diff --git a/alembic/versions/0b63f7c8ab96_add_tokens.py b/alembic/versions/1710345710_add_tokens.py similarity index 100% rename from alembic/versions/0b63f7c8ab96_add_tokens.py rename to alembic/versions/1710345710_add_tokens.py diff --git a/alembic/versions/1710945368_add_names_pronouns_fields.py b/alembic/versions/1710945368_add_names_pronouns_fields.py new file mode 100644 index 0000000..3c5dbcf --- /dev/null +++ b/alembic/versions/1710945368_add_names_pronouns_fields.py @@ -0,0 +1,54 @@ +"""Add names/pronouns/fields + +Revision ID: 1d8f8443a7f5 +Revises: 0b63f7c8ab96 +Create Date: 2024-03-20 15:36:08.756635 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision: str = "1d8f8443a7f5" +down_revision: Union[str, None] = "0b63f7c8ab96" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + op.add_column( + "users", + sa.Column( + "names", + postgresql.JSONB(astext_type=sa.Text()), + nullable=False, + server_default="[]", + ), + ) + op.add_column( + "users", + sa.Column( + "pronouns", + postgresql.JSONB(astext_type=sa.Text()), + nullable=False, + server_default="[]", + ), + ) + op.add_column( + "users", + sa.Column( + "fields", + postgresql.JSONB(astext_type=sa.Text()), + nullable=False, + server_default="[]", + ), + ) + + +def downgrade() -> None: + op.drop_column("users", "fields") + op.drop_column("users", "pronouns") + op.drop_column("users", "names") diff --git a/alembic/versions/1710946859_add_members.py b/alembic/versions/1710946859_add_members.py new file mode 100644 index 0000000..aa63228 --- /dev/null +++ b/alembic/versions/1710946859_add_members.py @@ -0,0 +1,41 @@ +"""Add members + +Revision ID: 17cc8cb77be5 +Revises: 1d8f8443a7f5 +Create Date: 2024-03-20 16:00:59.251354 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision: str = '17cc8cb77be5' +down_revision: Union[str, None] = '1d8f8443a7f5' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('members', + sa.Column('id', sa.BigInteger(), nullable=False), + sa.Column('name', sa.Text(), nullable=False), + sa.Column('display_name', sa.Text(), nullable=True), + sa.Column('bio', sa.Text(), nullable=True), + sa.Column('names', postgresql.JSONB(astext_type=sa.Text()), nullable=False), + sa.Column('pronouns', postgresql.JSONB(astext_type=sa.Text()), nullable=False), + sa.Column('fields', postgresql.JSONB(astext_type=sa.Text()), nullable=False), + sa.Column('user_id', sa.BigInteger(), nullable=False), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('members') + # ### end Alembic commands ###