more robust migrations
This commit is contained in:
@@ -19,23 +19,41 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('message')]
|
||||
|
||||
with op.batch_alter_table('message', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('has_attachment', sa.Boolean(), nullable=True))
|
||||
batch_op.add_column(sa.Column('attachment_name', sa.String(length=255), nullable=True))
|
||||
batch_op.add_column(sa.Column('attachment_path', sa.String(length=512), nullable=True))
|
||||
batch_op.add_column(sa.Column('attachment_type', sa.String(length=100), nullable=True))
|
||||
batch_op.add_column(sa.Column('attachment_size', sa.Integer(), nullable=True))
|
||||
if 'has_attachment' not in columns:
|
||||
batch_op.add_column(sa.Column('has_attachment', sa.Boolean(), nullable=True))
|
||||
if 'attachment_name' not in columns:
|
||||
batch_op.add_column(sa.Column('attachment_name', sa.String(length=255), nullable=True))
|
||||
if 'attachment_path' not in columns:
|
||||
batch_op.add_column(sa.Column('attachment_path', sa.String(length=512), nullable=True))
|
||||
if 'attachment_type' not in columns:
|
||||
batch_op.add_column(sa.Column('attachment_type', sa.String(length=100), nullable=True))
|
||||
if 'attachment_size' not in columns:
|
||||
batch_op.add_column(sa.Column('attachment_size', sa.Integer(), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('message')]
|
||||
|
||||
with op.batch_alter_table('message', schema=None) as batch_op:
|
||||
batch_op.drop_column('attachment_size')
|
||||
batch_op.drop_column('attachment_type')
|
||||
batch_op.drop_column('attachment_path')
|
||||
batch_op.drop_column('attachment_name')
|
||||
batch_op.drop_column('has_attachment')
|
||||
if 'attachment_size' in columns:
|
||||
batch_op.drop_column('attachment_size')
|
||||
if 'attachment_type' in columns:
|
||||
batch_op.drop_column('attachment_type')
|
||||
if 'attachment_path' in columns:
|
||||
batch_op.drop_column('attachment_path')
|
||||
if 'attachment_name' in columns:
|
||||
batch_op.drop_column('attachment_name')
|
||||
if 'has_attachment' in columns:
|
||||
batch_op.drop_column('has_attachment')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -22,23 +22,23 @@ def upgrade():
|
||||
conn = op.get_bind()
|
||||
inspector = sa.inspect(conn)
|
||||
if 'user' not in inspector.get_table_names():
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'user' not in tables:
|
||||
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')
|
||||
)
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'user' not in tables:
|
||||
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')
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('user')
|
||||
# ### end Alembic commands ###
|
||||
# ### end Alembic commands ###
|
||||
@@ -19,29 +19,29 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'mails' not in tables:
|
||||
op.create_table('mails',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('recipient', sa.String(length=150), nullable=False),
|
||||
sa.Column('subject', sa.String(length=200), nullable=False),
|
||||
sa.Column('body', sa.Text(), nullable=False),
|
||||
sa.Column('status', sa.String(length=20), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('sent_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('template_id', sa.Integer(), nullable=True),
|
||||
sa.Column('notif_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['notif_id'], ['notifs.id'], ),
|
||||
sa.ForeignKeyConstraint(['template_id'], ['email_templates.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('recipient', sa.String(length=150), nullable=False),
|
||||
sa.Column('subject', sa.String(length=200), nullable=False),
|
||||
sa.Column('body', sa.Text(), nullable=False),
|
||||
sa.Column('status', sa.String(length=20), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('sent_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('template_id', sa.Integer(), nullable=True),
|
||||
sa.Column('notif_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['notif_id'], ['notifs.id'], ),
|
||||
sa.ForeignKeyConstraint(['template_id'], ['email_templates.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('mails')
|
||||
# ### end Alembic commands ###
|
||||
# ### end Alembic commands ###
|
||||
@@ -19,15 +19,25 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('contact')]
|
||||
|
||||
with op.batch_alter_table('contact', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('is_admin', sa.Boolean(), nullable=True))
|
||||
if 'is_admin' not in columns:
|
||||
batch_op.add_column(sa.Column('is_admin', sa.Boolean(), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('contact')]
|
||||
|
||||
with op.batch_alter_table('contact', schema=None) as batch_op:
|
||||
batch_op.drop_column('is_admin')
|
||||
if 'is_admin' in columns:
|
||||
batch_op.drop_column('is_admin')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -25,18 +25,18 @@ def upgrade():
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'template_variables' not in tables:
|
||||
op.create_table('template_variables',
|
||||
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('notification_type', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
|
||||
sa.Column('variable_name', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
|
||||
sa.Column('description', sa.VARCHAR(length=200), autoincrement=False, nullable=False),
|
||||
sa.Column('example_value', sa.VARCHAR(length=200), autoincrement=False, nullable=True),
|
||||
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('template_variables_pkey'))
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('notification_type', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
|
||||
sa.Column('variable_name', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
|
||||
sa.Column('description', sa.VARCHAR(length=200), autoincrement=False, nullable=False),
|
||||
sa.Column('example_value', sa.VARCHAR(length=200), autoincrement=False, nullable=True),
|
||||
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('template_variables_pkey'))
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
@@ -19,27 +19,31 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'room_file' not in tables:
|
||||
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')
|
||||
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')
|
||||
)
|
||||
|
||||
# Check if preferred_view column exists before trying to drop it
|
||||
columns = [col['name'] for col in inspector.get_columns('room_member_permissions')]
|
||||
if 'preferred_view' in columns:
|
||||
with op.batch_alter_table('room_member_permissions', schema=None) as batch_op:
|
||||
batch_op.drop_column('preferred_view')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -50,4 +54,4 @@ def downgrade():
|
||||
batch_op.add_column(sa.Column('preferred_view', sa.VARCHAR(length=10), autoincrement=False, nullable=False))
|
||||
|
||||
op.drop_table('room_file')
|
||||
# ### end Alembic commands ###
|
||||
# ### end Alembic commands ###
|
||||
@@ -19,43 +19,63 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('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))
|
||||
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)
|
||||
if 'starred' not in columns:
|
||||
batch_op.add_column(sa.Column('starred', sa.Boolean(), nullable=True))
|
||||
|
||||
# Only alter columns if they exist
|
||||
if 'path' in columns:
|
||||
batch_op.alter_column('path',
|
||||
existing_type=sa.VARCHAR(length=1024),
|
||||
type_=sa.String(length=255),
|
||||
existing_nullable=False)
|
||||
if 'size' in columns:
|
||||
batch_op.alter_column('size',
|
||||
existing_type=sa.BIGINT(),
|
||||
type_=sa.Integer(),
|
||||
existing_nullable=True)
|
||||
if 'uploaded_by' in columns:
|
||||
batch_op.alter_column('uploaded_by',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
if 'uploaded_at' in columns:
|
||||
batch_op.alter_column('uploaded_at',
|
||||
existing_type=postgresql.TIMESTAMP(),
|
||||
nullable=True)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('room_file')]
|
||||
|
||||
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')
|
||||
if 'uploaded_at' in columns:
|
||||
batch_op.alter_column('uploaded_at',
|
||||
existing_type=postgresql.TIMESTAMP(),
|
||||
nullable=False)
|
||||
if 'uploaded_by' in columns:
|
||||
batch_op.alter_column('uploaded_by',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
if 'size' in columns:
|
||||
batch_op.alter_column('size',
|
||||
existing_type=sa.Integer(),
|
||||
type_=sa.BIGINT(),
|
||||
existing_nullable=True)
|
||||
if 'path' in columns:
|
||||
batch_op.alter_column('path',
|
||||
existing_type=sa.String(length=255),
|
||||
type_=sa.VARCHAR(length=1024),
|
||||
existing_nullable=False)
|
||||
if 'starred' in columns:
|
||||
batch_op.drop_column('starred')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -19,17 +19,31 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('site_settings')]
|
||||
|
||||
with op.batch_alter_table('site_settings', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('company_website', sa.String(length=200), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_email', sa.String(length=100), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_phone', sa.String(length=20), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_address', sa.String(length=200), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_city', sa.String(length=100), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_state', sa.String(length=100), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_zip', sa.String(length=20), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_country', sa.String(length=100), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_description', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_industry', sa.String(length=100), nullable=True))
|
||||
if 'company_website' not in columns:
|
||||
batch_op.add_column(sa.Column('company_website', sa.String(length=200), nullable=True))
|
||||
if 'company_email' not in columns:
|
||||
batch_op.add_column(sa.Column('company_email', sa.String(length=100), nullable=True))
|
||||
if 'company_phone' not in columns:
|
||||
batch_op.add_column(sa.Column('company_phone', sa.String(length=20), nullable=True))
|
||||
if 'company_address' not in columns:
|
||||
batch_op.add_column(sa.Column('company_address', sa.String(length=200), nullable=True))
|
||||
if 'company_city' not in columns:
|
||||
batch_op.add_column(sa.Column('company_city', sa.String(length=100), nullable=True))
|
||||
if 'company_state' not in columns:
|
||||
batch_op.add_column(sa.Column('company_state', sa.String(length=100), nullable=True))
|
||||
if 'company_zip' not in columns:
|
||||
batch_op.add_column(sa.Column('company_zip', sa.String(length=20), nullable=True))
|
||||
if 'company_country' not in columns:
|
||||
batch_op.add_column(sa.Column('company_country', sa.String(length=100), nullable=True))
|
||||
if 'company_description' not in columns:
|
||||
batch_op.add_column(sa.Column('company_description', sa.Text(), nullable=True))
|
||||
if 'company_industry' not in columns:
|
||||
batch_op.add_column(sa.Column('company_industry', sa.String(length=100), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import sqlalchemy as sa
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9faab7ef6036'
|
||||
down_revision = 'ca9026520dad'
|
||||
@@ -19,35 +20,35 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'site_settings' not in tables:
|
||||
op.create_table('site_settings',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('primary_color', sa.String(length=7), nullable=True),
|
||||
sa.Column('secondary_color', sa.String(length=7), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('primary_color', sa.String(length=7), nullable=True),
|
||||
sa.Column('secondary_color', sa.String(length=7), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.drop_table('color_settings')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'color_settings' not in tables:
|
||||
op.create_table('color_settings',
|
||||
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('primary_color', sa.VARCHAR(length=7), autoincrement=False, nullable=True),
|
||||
sa.Column('secondary_color', sa.VARCHAR(length=7), autoincrement=False, nullable=True),
|
||||
sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('color_settings_pkey'))
|
||||
)
|
||||
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('primary_color', sa.VARCHAR(length=7), autoincrement=False, nullable=True),
|
||||
sa.Column('secondary_color', sa.VARCHAR(length=7), autoincrement=False, nullable=True),
|
||||
sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('color_settings_pkey'))
|
||||
)
|
||||
op.drop_table('site_settings')
|
||||
# ### end Alembic commands ###
|
||||
# ### end Alembic commands ###
|
||||
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -19,51 +19,51 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# Create conversation table first
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'conversation' not in tables:
|
||||
op.create_table('conversation',
|
||||
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.ForeignKeyConstraint(['created_by'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
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.ForeignKeyConstraint(['created_by'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
# Create conversation_members table
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'conversation_members' not in tables:
|
||||
op.create_table('conversation_members',
|
||||
sa.Column('conversation_id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['conversation_id'], ['conversation.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('conversation_id', 'user_id')
|
||||
)
|
||||
sa.Column('conversation_id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['conversation_id'], ['conversation.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('conversation_id', 'user_id')
|
||||
)
|
||||
|
||||
# Create message table
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'message' not in tables:
|
||||
op.create_table('message',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('content', sa.Text(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('conversation_id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['conversation_id'], ['conversation.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('content', sa.Text(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('conversation_id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['conversation_id'], ['conversation.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
@@ -17,9 +17,15 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('room_file')]
|
||||
|
||||
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))
|
||||
if 'deleted_by' not in columns:
|
||||
batch_op.add_column(sa.Column('deleted_by', sa.Integer(), nullable=True))
|
||||
if 'deleted_at' not in columns:
|
||||
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 ###
|
||||
|
||||
@@ -17,8 +17,13 @@ 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'))
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('room_file')]
|
||||
|
||||
if 'deleted' not in columns:
|
||||
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 ###
|
||||
|
||||
|
||||
@@ -18,28 +18,28 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'trashed_file' not in tables:
|
||||
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')
|
||||
)
|
||||
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():
|
||||
|
||||
@@ -18,14 +18,20 @@ 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)
|
||||
# Check if the column exists before adding it
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('user')]
|
||||
|
||||
if 'preferred_view' not in columns:
|
||||
# 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():
|
||||
|
||||
@@ -19,10 +19,17 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('room_member_permissions')]
|
||||
|
||||
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()))
|
||||
if 'can_download' not in columns:
|
||||
batch_op.add_column(sa.Column('can_download', sa.Boolean(), nullable=False, server_default=sa.false()))
|
||||
if 'can_rename' not in columns:
|
||||
batch_op.add_column(sa.Column('can_rename', sa.Boolean(), nullable=False, server_default=sa.false()))
|
||||
if 'can_move' not in columns:
|
||||
batch_op.add_column(sa.Column('can_move', sa.Boolean(), nullable=False, server_default=sa.false()))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
@@ -19,11 +19,14 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('contact')
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
columns = [col['name'] for col in inspector.get_columns('user')]
|
||||
|
||||
if 'contact' in tables:
|
||||
op.drop_table('contact')
|
||||
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
if 'profile_picture' not in columns:
|
||||
batch_op.add_column(sa.Column('profile_picture', sa.String(length=255), nullable=True))
|
||||
@@ -33,8 +36,13 @@ def upgrade():
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('user')]
|
||||
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.drop_column('profile_picture')
|
||||
if 'profile_picture' in columns:
|
||||
batch_op.drop_column('profile_picture')
|
||||
|
||||
op.create_table('contact',
|
||||
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
||||
|
||||
@@ -32,7 +32,12 @@ def upgrade():
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('user')]
|
||||
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.drop_column('last_name')
|
||||
if 'last_name' in columns:
|
||||
batch_op.drop_column('last_name')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -19,23 +19,23 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'email_templates' not in tables:
|
||||
op.create_table('email_templates',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=100), nullable=False),
|
||||
sa.Column('subject', sa.String(length=200), nullable=False),
|
||||
sa.Column('body', sa.Text(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('created_by', sa.Integer(), nullable=False),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['created_by'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=100), nullable=False),
|
||||
sa.Column('subject', sa.String(length=200), nullable=False),
|
||||
sa.Column('body', sa.Text(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('created_by', sa.Integer(), nullable=False),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['created_by'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.drop_table('notification')
|
||||
with op.batch_alter_table('events', schema=None) as batch_op:
|
||||
batch_op.alter_column('details',
|
||||
@@ -60,22 +60,22 @@ def downgrade():
|
||||
type_=postgresql.JSONB(astext_type=sa.Text()),
|
||||
existing_nullable=True)
|
||||
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'notification' not in tables:
|
||||
op.create_table('notification',
|
||||
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('title', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
|
||||
sa.Column('message', sa.TEXT(), autoincrement=False, nullable=False),
|
||||
sa.Column('type', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
|
||||
sa.Column('is_read', sa.BOOLEAN(), autoincrement=False, nullable=True),
|
||||
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
||||
sa.Column('link', sa.VARCHAR(length=512), autoincrement=False, nullable=True),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('notification_user_id_fkey')),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('notification_pkey'))
|
||||
)
|
||||
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('title', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
|
||||
sa.Column('message', sa.TEXT(), autoincrement=False, nullable=False),
|
||||
sa.Column('type', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
|
||||
sa.Column('is_read', sa.BOOLEAN(), autoincrement=False, nullable=True),
|
||||
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
||||
sa.Column('link', sa.VARCHAR(length=512), autoincrement=False, nullable=True),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('notification_user_id_fkey')),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('notification_pkey'))
|
||||
)
|
||||
op.drop_table('email_templates')
|
||||
# ### end Alembic commands ###
|
||||
# ### end Alembic commands ###
|
||||
@@ -19,18 +19,18 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'color_settings' not in tables:
|
||||
op.create_table('color_settings',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('primary_color', sa.String(length=7), nullable=True),
|
||||
sa.Column('secondary_color', sa.String(length=7), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('primary_color', sa.String(length=7), nullable=True),
|
||||
sa.Column('secondary_color', sa.String(length=7), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
with op.batch_alter_table('room_file', schema=None) as batch_op:
|
||||
batch_op.alter_column('deleted',
|
||||
existing_type=sa.BOOLEAN(),
|
||||
@@ -59,4 +59,4 @@ def downgrade():
|
||||
existing_server_default=sa.text('false'))
|
||||
|
||||
op.drop_table('color_settings')
|
||||
# ### end Alembic commands ###
|
||||
# ### end Alembic commands ###
|
||||
@@ -18,21 +18,21 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# Create user_starred_file table
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'user_starred_file' not in tables:
|
||||
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')
|
||||
)
|
||||
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:
|
||||
|
||||
@@ -19,21 +19,31 @@ 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)
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('user')]
|
||||
|
||||
if 'password_hash' in columns:
|
||||
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)
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('user')]
|
||||
|
||||
if 'password_hash' in columns:
|
||||
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 ###
|
||||
|
||||
@@ -19,27 +19,30 @@ 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')
|
||||
)
|
||||
|
||||
# Check if columns exist before adding them
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'contact' not in tables:
|
||||
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')
|
||||
)
|
||||
|
||||
# Check if columns exist before adding them
|
||||
columns = [col['name'] for col in inspector.get_columns('user')]
|
||||
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
@@ -53,9 +56,15 @@ def upgrade():
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('user')]
|
||||
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.drop_column('created_at')
|
||||
batch_op.drop_column('is_admin')
|
||||
if 'created_at' in columns:
|
||||
batch_op.drop_column('created_at')
|
||||
if 'is_admin' in columns:
|
||||
batch_op.drop_column('is_admin')
|
||||
|
||||
op.drop_table('contact')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -19,22 +19,22 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'message_attachment' not in tables:
|
||||
op.create_table('message_attachment',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('message_id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('path', sa.String(length=512), nullable=False),
|
||||
sa.Column('type', sa.String(length=100), nullable=True),
|
||||
sa.Column('size', sa.Integer(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['message_id'], ['message.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('message_id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('path', sa.String(length=512), nullable=False),
|
||||
sa.Column('type', sa.String(length=100), nullable=True),
|
||||
sa.Column('size', sa.Integer(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['message_id'], ['message.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
with op.batch_alter_table('message', schema=None) as batch_op:
|
||||
batch_op.drop_column('attachment_path')
|
||||
batch_op.drop_column('attachment_type')
|
||||
@@ -55,4 +55,4 @@ def downgrade():
|
||||
batch_op.add_column(sa.Column('attachment_path', sa.VARCHAR(length=512), autoincrement=False, nullable=True))
|
||||
|
||||
op.drop_table('message_attachment')
|
||||
# ### end Alembic commands ###
|
||||
# ### end Alembic commands ###
|
||||
@@ -19,8 +19,13 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('site_settings', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('company_logo', sa.String(length=255), nullable=True))
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('site_settings')]
|
||||
|
||||
if 'company_logo' not in columns:
|
||||
with op.batch_alter_table('site_settings', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('company_logo', sa.String(length=255), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
Reference in New Issue
Block a user