/ migrations / versions / 019_add_project_comments.py
019_add_project_comments.py
 1  from alembic import op
 2  import sqlalchemy as sa
 3  
 4  revision = '019'
 5  down_revision = '018'
 6  branch_labels = None
 7  depends_on = None
 8  
 9  def upgrade():
10      try:
11          op.create_table(
12              'project_comments',
13              sa.Column('id', sa.Integer(), primary_key=True, index=True),
14              sa.Column('project_id', sa.Integer(), sa.ForeignKey('projects.id'), nullable=False, index=True),
15              sa.Column('user_id', sa.Integer(), sa.ForeignKey('users.id'), nullable=False),
16              sa.Column('content', sa.Text(), nullable=False),
17              sa.Column('created_at', sa.DateTime(), nullable=False, index=True),
18              sa.Column('updated_at', sa.DateTime(), nullable=False),
19          )
20      except Exception as e:
21          print(f"Error creating project_comments: {e}")
22  
23  def downgrade():
24      try:
25          op.drop_table('project_comments')
26      except Exception as e:
27          print(f"Error dropping project_comments: {e}")