first
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""Add user authentication fields
|
||||
|
||||
Revision ID: 1c297825e3a9
|
||||
Revises:
|
||||
Create Date: 2025-05-23 08:39:40.494853
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1c297825e3a9'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('user',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('username', sa.String(length=150), nullable=False),
|
||||
sa.Column('email', sa.String(length=150), nullable=False),
|
||||
sa.Column('password_hash', sa.String(length=128), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('email'),
|
||||
sa.UniqueConstraint('username')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('user')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,32 @@
|
||||
"""Add is_admin to Contact model
|
||||
|
||||
Revision ID: 25da158dd705
|
||||
Revises: 7a5747dc773f
|
||||
Create Date: 2025-05-23 16:10:53.731035
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '25da158dd705'
|
||||
down_revision = '7a5747dc773f'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('contact', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('is_admin', sa.Boolean(), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('contact', schema=None) as batch_op:
|
||||
batch_op.drop_column('is_admin')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Add room member permissions table
|
||||
|
||||
Revision ID: 26b0e5357f52
|
||||
Revises: 2c5f57dddb78
|
||||
Create Date: 2025-05-23 21:44:58.832286
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '26b0e5357f52'
|
||||
down_revision = '2c5f57dddb78'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('room_member_permissions',
|
||||
sa.Column('room_id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('can_view', sa.Boolean(), nullable=False),
|
||||
sa.Column('can_upload', sa.Boolean(), nullable=False),
|
||||
sa.Column('can_delete', sa.Boolean(), nullable=False),
|
||||
sa.Column('can_share', sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['room_id'], ['room.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('room_id', 'user_id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('room_member_permissions')
|
||||
# ### end Alembic commands ###
|
||||
40
migrations/versions/2c5f57dddb78_add_room_members_table.py
Normal file
40
migrations/versions/2c5f57dddb78_add_room_members_table.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""Add room members table
|
||||
|
||||
Revision ID: 2c5f57dddb78
|
||||
Revises: 3a5b8d8e53cd
|
||||
Create Date: 2025-05-23 21:27:17.497481
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2c5f57dddb78'
|
||||
down_revision = '3a5b8d8e53cd'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('room_members',
|
||||
sa.Column('room_id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['room_id'], ['room.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('room_id', 'user_id')
|
||||
)
|
||||
with op.batch_alter_table('room', schema=None) as batch_op:
|
||||
batch_op.drop_column('is_private')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('room', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('is_private', sa.BOOLEAN(), autoincrement=False, nullable=True))
|
||||
|
||||
op.drop_table('room_members')
|
||||
# ### end Alembic commands ###
|
||||
37
migrations/versions/3a5b8d8e53cd_add_rooms_table.py
Normal file
37
migrations/versions/3a5b8d8e53cd_add_rooms_table.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""Add rooms table
|
||||
|
||||
Revision ID: 3a5b8d8e53cd
|
||||
Revises: c21f243b3640
|
||||
Create Date: 2025-05-23 21:25:27.880150
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3a5b8d8e53cd'
|
||||
down_revision = 'c21f243b3640'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('room',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=100), nullable=False),
|
||||
sa.Column('description', sa.Text(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('created_by', sa.Integer(), nullable=False),
|
||||
sa.Column('is_private', sa.Boolean(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['created_by'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('room')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,40 @@
|
||||
"""Add contact fields to User model
|
||||
|
||||
Revision ID: 43dfd2543fad
|
||||
Revises: dbcb5d2d3ed0
|
||||
Create Date: 2025-05-23 09:24:23.926302
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '43dfd2543fad'
|
||||
down_revision = 'dbcb5d2d3ed0'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('phone', sa.String(length=20), nullable=True))
|
||||
batch_op.add_column(sa.Column('company', sa.String(length=100), nullable=True))
|
||||
batch_op.add_column(sa.Column('position', sa.String(length=100), nullable=True))
|
||||
batch_op.add_column(sa.Column('notes', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('is_active', sa.Boolean(), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.drop_column('is_active')
|
||||
batch_op.drop_column('notes')
|
||||
batch_op.drop_column('position')
|
||||
batch_op.drop_column('company')
|
||||
batch_op.drop_column('phone')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,47 @@
|
||||
"""add room_file table for file/folder metadata and uploader info
|
||||
|
||||
Revision ID: 64b5c28510b0
|
||||
Revises: b978642e7b10
|
||||
Create Date: 2025-05-24 10:07:02.159730
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '64b5c28510b0'
|
||||
down_revision = 'b978642e7b10'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('room_file',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('room_id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('path', sa.String(length=1024), nullable=False),
|
||||
sa.Column('type', sa.String(length=10), nullable=False),
|
||||
sa.Column('size', sa.BigInteger(), nullable=True),
|
||||
sa.Column('modified', sa.Float(), nullable=True),
|
||||
sa.Column('uploaded_by', sa.Integer(), nullable=False),
|
||||
sa.Column('uploaded_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['room_id'], ['room.id'], ),
|
||||
sa.ForeignKeyConstraint(['uploaded_by'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
with op.batch_alter_table('room_member_permissions', schema=None) as batch_op:
|
||||
batch_op.drop_column('preferred_view')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('room_member_permissions', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('preferred_view', sa.VARCHAR(length=10), autoincrement=False, nullable=False))
|
||||
|
||||
op.drop_table('room_file')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,60 @@
|
||||
"""Add starred column to room_file table
|
||||
|
||||
Revision ID: 6651332488d9
|
||||
Revises: be1f7bdd10e1
|
||||
Create Date: 2025-05-24 18:14:38.320999
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '6651332488d9'
|
||||
down_revision = 'be1f7bdd10e1'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('room_file', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('starred', sa.Boolean(), nullable=True))
|
||||
batch_op.alter_column('path',
|
||||
existing_type=sa.VARCHAR(length=1024),
|
||||
type_=sa.String(length=255),
|
||||
existing_nullable=False)
|
||||
batch_op.alter_column('size',
|
||||
existing_type=sa.BIGINT(),
|
||||
type_=sa.Integer(),
|
||||
existing_nullable=True)
|
||||
batch_op.alter_column('uploaded_by',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('uploaded_at',
|
||||
existing_type=postgresql.TIMESTAMP(),
|
||||
nullable=True)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('room_file', schema=None) as batch_op:
|
||||
batch_op.alter_column('uploaded_at',
|
||||
existing_type=postgresql.TIMESTAMP(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('uploaded_by',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('size',
|
||||
existing_type=sa.Integer(),
|
||||
type_=sa.BIGINT(),
|
||||
existing_nullable=True)
|
||||
batch_op.alter_column('path',
|
||||
existing_type=sa.String(length=255),
|
||||
type_=sa.VARCHAR(length=1024),
|
||||
existing_nullable=False)
|
||||
batch_op.drop_column('starred')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
34
migrations/versions/7554ab70efe7_fix_existing_users.py
Normal file
34
migrations/versions/7554ab70efe7_fix_existing_users.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""fix existing users
|
||||
|
||||
Revision ID: 7554ab70efe7
|
||||
Revises: 43dfd2543fad
|
||||
Create Date: 2024-03-19 10:05:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.sql import text
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7554ab70efe7'
|
||||
down_revision = '43dfd2543fad'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# Update existing users to set default values
|
||||
connection = op.get_bind()
|
||||
connection.execute(
|
||||
text("""
|
||||
UPDATE "user"
|
||||
SET position = 'Administrator',
|
||||
is_active = true
|
||||
WHERE position IS NULL
|
||||
""")
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
24
migrations/versions/76da0573e84b_merge_heads.py
Normal file
24
migrations/versions/76da0573e84b_merge_heads.py
Normal file
@@ -0,0 +1,24 @@
|
||||
"""merge heads
|
||||
|
||||
Revision ID: 76da0573e84b
|
||||
Revises: add_deleted_by_to_room_file, create_user_starred_file_table
|
||||
Create Date: 2025-05-25 10:03:03.423064
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '76da0573e84b'
|
||||
down_revision = ('add_deleted_by_to_room_file', 'create_user_starred_file_table')
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
pass
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
@@ -0,0 +1,42 @@
|
||||
"""Update last_name field in User model
|
||||
|
||||
Revision ID: 7a5747dc773f
|
||||
Revises: c243d6a1843d
|
||||
Create Date: 2024-03-19 10:15:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.sql import text
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7a5747dc773f'
|
||||
down_revision = 'c243d6a1843d'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# First, update any null last_name values to '(You)'
|
||||
connection = op.get_bind()
|
||||
connection.execute(
|
||||
text("""
|
||||
UPDATE "user"
|
||||
SET last_name = '(You)'
|
||||
WHERE last_name IS NULL
|
||||
""")
|
||||
)
|
||||
|
||||
# Then make the column non-nullable
|
||||
op.alter_column('user', 'last_name',
|
||||
existing_type=sa.String(length=150),
|
||||
nullable=False,
|
||||
server_default='(You)')
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.alter_column('user', 'last_name',
|
||||
existing_type=sa.String(length=150),
|
||||
nullable=True,
|
||||
server_default=None)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
33
migrations/versions/add_deleted_by_to_room_file.py
Normal file
33
migrations/versions/add_deleted_by_to_room_file.py
Normal file
@@ -0,0 +1,33 @@
|
||||
"""Add deleted_by column to room_file table
|
||||
|
||||
Revision ID: add_deleted_by_to_room_file
|
||||
Revises: add_deleted_column_to_room_file
|
||||
Create Date: 2024-03-19 10:45:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'add_deleted_by_to_room_file'
|
||||
down_revision = 'add_deleted_column_to_room_file'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('room_file', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('deleted_by', sa.Integer(), nullable=True))
|
||||
batch_op.add_column(sa.Column('deleted_at', sa.DateTime(), nullable=True))
|
||||
batch_op.create_foreign_key('fk_room_file_deleted_by_user', 'user', ['deleted_by'], ['id'])
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('room_file', schema=None) as batch_op:
|
||||
batch_op.drop_constraint('fk_room_file_deleted_by_user', type_='foreignkey')
|
||||
batch_op.drop_column('deleted_at')
|
||||
batch_op.drop_column('deleted_by')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
29
migrations/versions/add_deleted_column_to_room_file.py
Normal file
29
migrations/versions/add_deleted_column_to_room_file.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""Add deleted column to room_file table
|
||||
|
||||
Revision ID: add_deleted_column_to_room_file
|
||||
Revises: add_trashed_file_table
|
||||
Create Date: 2024-03-19 10:30:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'add_deleted_column_to_room_file'
|
||||
down_revision = 'add_trashed_file_table'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('room_file', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('deleted', sa.Boolean(), nullable=False, server_default='false'))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('room_file', schema=None) as batch_op:
|
||||
batch_op.drop_column('deleted')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
42
migrations/versions/add_trashed_file_table.py
Normal file
42
migrations/versions/add_trashed_file_table.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""Add trashed file table
|
||||
|
||||
Revision ID: add_trashed_file_table
|
||||
Revises: 6651332488d9
|
||||
Create Date: 2024-03-19 10:00:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'add_trashed_file_table'
|
||||
down_revision = '6651332488d9'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('trashed_file',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('room_id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('original_path', sa.String(length=255), nullable=False),
|
||||
sa.Column('type', sa.String(length=10), nullable=False),
|
||||
sa.Column('size', sa.Integer(), nullable=True),
|
||||
sa.Column('modified', sa.Float(), nullable=True),
|
||||
sa.Column('uploaded_by', sa.Integer(), nullable=True),
|
||||
sa.Column('uploaded_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('deleted_by', sa.Integer(), nullable=False),
|
||||
sa.Column('deleted_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['deleted_by'], ['user.id'], ),
|
||||
sa.ForeignKeyConstraint(['room_id'], ['room.id'], ),
|
||||
sa.ForeignKeyConstraint(['uploaded_by'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('trashed_file')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,38 @@
|
||||
"""add preferred_view to user
|
||||
|
||||
Revision ID: b978642e7b10
|
||||
Revises: 26b0e5357f52
|
||||
Create Date: 2025-05-24 08:36:03.426879
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b978642e7b10'
|
||||
down_revision = '26b0e5357f52'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# Add preferred_view as nullable first
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('preferred_view', sa.String(length=10), nullable=True))
|
||||
# Set default value for existing users
|
||||
op.execute("UPDATE \"user\" SET preferred_view = 'grid'")
|
||||
# Make the column non-nullable
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.alter_column('preferred_view', nullable=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.drop_column('preferred_view')
|
||||
|
||||
with op.batch_alter_table('room_member_permissions', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('preferred_view', sa.VARCHAR(length=10), autoincrement=False, nullable=False))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,36 @@
|
||||
"""Add granular permissions to RoomMemberPermission
|
||||
|
||||
Revision ID: be1f7bdd10e1
|
||||
Revises: 64b5c28510b0
|
||||
Create Date: 2025-05-24 12:32:19.239241
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'be1f7bdd10e1'
|
||||
down_revision = '64b5c28510b0'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('room_member_permissions', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('can_download', sa.Boolean(), nullable=False, server_default=sa.false()))
|
||||
batch_op.add_column(sa.Column('can_rename', sa.Boolean(), nullable=False, server_default=sa.false()))
|
||||
batch_op.add_column(sa.Column('can_move', sa.Boolean(), nullable=False, server_default=sa.false()))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('room_member_permissions', schema=None) as batch_op:
|
||||
batch_op.drop_column('can_move')
|
||||
batch_op.drop_column('can_rename')
|
||||
batch_op.drop_column('can_download')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,51 @@
|
||||
"""add profile_picture to user
|
||||
|
||||
Revision ID: c21f243b3640
|
||||
Revises: 25da158dd705
|
||||
Create Date: 2025-05-23 19:28:16.977187
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c21f243b3640'
|
||||
down_revision = '25da158dd705'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('contact')
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('profile_picture', sa.String(length=255), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.drop_column('profile_picture')
|
||||
|
||||
op.create_table('contact',
|
||||
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('first_name', sa.VARCHAR(length=100), autoincrement=False, nullable=False),
|
||||
sa.Column('last_name', sa.VARCHAR(length=100), autoincrement=False, nullable=False),
|
||||
sa.Column('email', sa.VARCHAR(length=150), autoincrement=False, nullable=False),
|
||||
sa.Column('phone', sa.VARCHAR(length=20), autoincrement=False, nullable=True),
|
||||
sa.Column('company', sa.VARCHAR(length=100), autoincrement=False, nullable=True),
|
||||
sa.Column('position', sa.VARCHAR(length=100), autoincrement=False, nullable=True),
|
||||
sa.Column('notes', sa.TEXT(), autoincrement=False, nullable=True),
|
||||
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
||||
sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
||||
sa.Column('owner_id', sa.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=True),
|
||||
sa.Column('is_admin', sa.BOOLEAN(), autoincrement=False, nullable=True),
|
||||
sa.ForeignKeyConstraint(['owner_id'], ['user.id'], name=op.f('contact_owner_id_fkey')),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('contact_pkey')),
|
||||
sa.UniqueConstraint('email', name=op.f('contact_email_key'), postgresql_include=[], postgresql_nulls_not_distinct=False)
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,32 @@
|
||||
"""Add last_name to User model
|
||||
|
||||
Revision ID: c243d6a1843d
|
||||
Revises: 7554ab70efe7
|
||||
Create Date: 2025-05-23 16:00:09.905001
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c243d6a1843d'
|
||||
down_revision = '7554ab70efe7'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('last_name', sa.String(length=150), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.drop_column('last_name')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
41
migrations/versions/create_user_starred_file_table.py
Normal file
41
migrations/versions/create_user_starred_file_table.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""Create user_starred_file table and remove starred column
|
||||
|
||||
Revision ID: create_user_starred_file_table
|
||||
Revises: 6651332488d9
|
||||
Create Date: 2024-03-19 10:00:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'create_user_starred_file_table'
|
||||
down_revision = '6651332488d9'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# Create user_starred_file table
|
||||
op.create_table('user_starred_file',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('file_id', sa.Integer(), nullable=False),
|
||||
sa.Column('starred_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['file_id'], ['room_file.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('user_id', 'file_id', name='unique_user_file_star')
|
||||
)
|
||||
|
||||
# Remove starred column from room_file
|
||||
with op.batch_alter_table('room_file', schema=None) as batch_op:
|
||||
batch_op.drop_column('starred')
|
||||
|
||||
def downgrade():
|
||||
# Add starred column back to room_file
|
||||
with op.batch_alter_table('room_file', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('starred', sa.Boolean(), nullable=True))
|
||||
|
||||
# Drop user_starred_file table
|
||||
op.drop_table('user_starred_file')
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Increase password_hash column length
|
||||
|
||||
Revision ID: d8dcbf9fe881
|
||||
Revises: 1c297825e3a9
|
||||
Create Date: 2025-05-23 08:45:00.693155
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd8dcbf9fe881'
|
||||
down_revision = '1c297825e3a9'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.alter_column('password_hash',
|
||||
existing_type=sa.VARCHAR(length=128),
|
||||
type_=sa.String(length=256),
|
||||
existing_nullable=True)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.alter_column('password_hash',
|
||||
existing_type=sa.String(length=256),
|
||||
type_=sa.VARCHAR(length=128),
|
||||
existing_nullable=True)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
52
migrations/versions/dbcb5d2d3ed0_add_contact_model.py
Normal file
52
migrations/versions/dbcb5d2d3ed0_add_contact_model.py
Normal file
@@ -0,0 +1,52 @@
|
||||
"""Add Contact model
|
||||
|
||||
Revision ID: dbcb5d2d3ed0
|
||||
Revises: d8dcbf9fe881
|
||||
Create Date: 2025-05-23 08:55:10.537722
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'dbcb5d2d3ed0'
|
||||
down_revision = 'd8dcbf9fe881'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('contact',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('first_name', sa.String(length=100), nullable=False),
|
||||
sa.Column('last_name', sa.String(length=100), nullable=False),
|
||||
sa.Column('email', sa.String(length=150), nullable=False),
|
||||
sa.Column('phone', sa.String(length=20), nullable=True),
|
||||
sa.Column('company', sa.String(length=100), nullable=True),
|
||||
sa.Column('position', sa.String(length=100), nullable=True),
|
||||
sa.Column('notes', sa.Text(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('owner_id', sa.Integer(), nullable=False),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['owner_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('email')
|
||||
)
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('is_admin', sa.Boolean(), nullable=True))
|
||||
batch_op.add_column(sa.Column('created_at', sa.DateTime(), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.drop_column('created_at')
|
||||
batch_op.drop_column('is_admin')
|
||||
|
||||
op.drop_table('contact')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user