updates
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
57
Backend/alembic/versions/add_blog_posts_table.py
Normal file
57
Backend/alembic/versions/add_blog_posts_table.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""add blog posts table
|
||||
|
||||
Revision ID: add_blog_posts
|
||||
Revises: fff4b67466b3
|
||||
Create Date: 2024-01-01 12:00:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'add_blog_posts'
|
||||
down_revision = 'fff4b67466b3' # Update this to the latest migration
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
'blog_posts',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('title', sa.String(length=500), nullable=False),
|
||||
sa.Column('slug', sa.String(length=500), nullable=False),
|
||||
sa.Column('excerpt', sa.Text(), nullable=True),
|
||||
sa.Column('content', sa.Text(), nullable=False),
|
||||
sa.Column('featured_image', sa.String(length=1000), nullable=True),
|
||||
sa.Column('author_id', sa.Integer(), nullable=False),
|
||||
sa.Column('published_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('is_published', sa.Boolean(), nullable=False, server_default='0'),
|
||||
sa.Column('tags', sa.Text(), nullable=True),
|
||||
sa.Column('meta_title', sa.String(length=500), nullable=True),
|
||||
sa.Column('meta_description', sa.Text(), nullable=True),
|
||||
sa.Column('meta_keywords', sa.String(length=1000), nullable=True),
|
||||
sa.Column('views_count', sa.Integer(), nullable=False, server_default='0'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_blog_posts_id'), 'blog_posts', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_blog_posts_title'), 'blog_posts', ['title'], unique=False)
|
||||
op.create_index(op.f('ix_blog_posts_slug'), 'blog_posts', ['slug'], unique=True)
|
||||
op.create_index(op.f('ix_blog_posts_author_id'), 'blog_posts', ['author_id'], unique=False)
|
||||
op.create_index(op.f('ix_blog_posts_published_at'), 'blog_posts', ['published_at'], unique=False)
|
||||
op.create_index(op.f('ix_blog_posts_is_published'), 'blog_posts', ['is_published'], unique=False)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index(op.f('ix_blog_posts_is_published'), table_name='blog_posts')
|
||||
op.drop_index(op.f('ix_blog_posts_published_at'), table_name='blog_posts')
|
||||
op.drop_index(op.f('ix_blog_posts_author_id'), table_name='blog_posts')
|
||||
op.drop_index(op.f('ix_blog_posts_slug'), table_name='blog_posts')
|
||||
op.drop_index(op.f('ix_blog_posts_title'), table_name='blog_posts')
|
||||
op.drop_index(op.f('ix_blog_posts_id'), table_name='blog_posts')
|
||||
op.drop_table('blog_posts')
|
||||
|
||||
27
Backend/alembic/versions/add_sections_to_blog_posts.py
Normal file
27
Backend/alembic/versions/add_sections_to_blog_posts.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""add sections to blog posts
|
||||
|
||||
Revision ID: add_sections_blog
|
||||
Revises: add_blog_posts
|
||||
Create Date: 2024-01-02 12:00:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'add_sections_blog'
|
||||
down_revision = 'add_blog_posts' # Depends on blog_posts table migration
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Add sections JSON column to blog_posts table
|
||||
op.add_column('blog_posts', sa.Column('sections', sa.JSON(), nullable=True))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Remove sections column
|
||||
op.drop_column('blog_posts', 'sections')
|
||||
|
||||
Reference in New Issue
Block a user