feat: ability to add and view blogs for a user

This commit is contained in:
2025-06-24 18:54:48 -04:00
parent 07c0977aa7
commit 7da38ddd8c
26 changed files with 1553 additions and 142 deletions
+104
View File
@@ -0,0 +1,104 @@
"""empty message
Revision ID: f6c8aa750e08
Revises: 273690fd257d
Create Date: 2025-06-22 14:14:03.560792
"""
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 = "f6c8aa750e08"
down_revision: Union[str, None] = "273690fd257d"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("ix_blogs_author_id"), table_name="blogs")
op.drop_index(op.f("ix_blogs_id"), table_name="blogs")
op.drop_index(op.f("ix_blogs_title"), table_name="blogs")
op.drop_table("blogs")
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"blogs",
sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column("title", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column("author_id", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column("description", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column(
"body",
postgresql.JSON(astext_type=sa.Text()),
autoincrement=False,
nullable=False,
),
sa.Column(
"created_at",
postgresql.TIMESTAMP(timezone=True),
server_default=sa.text("now()"),
autoincrement=False,
nullable=False,
),
sa.Column(
"updated_at",
postgresql.TIMESTAMP(timezone=True),
autoincrement=False,
nullable=True,
),
sa.Column(
"published_at",
postgresql.TIMESTAMP(timezone=True),
autoincrement=False,
nullable=True,
),
sa.Column("word_count", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column("version", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column("read_time", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column("language", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column(
"tags",
postgresql.JSON(astext_type=sa.Text()),
autoincrement=False,
nullable=True,
),
sa.Column("view_count", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("like_count", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["author_id"], ["users.id"], name=op.f("blogs_author_id_fkey")
),
sa.PrimaryKeyConstraint("id", name=op.f("blogs_pkey")),
)
op.create_index(op.f("ix_blogs_title"), "blogs", ["title"], unique=False)
op.create_index(op.f("ix_blogs_id"), "blogs", ["id"], unique=False)
op.create_index(op.f("ix_blogs_author_id"), "blogs", ["author_id"], unique=False)
op.create_table(
"users",
sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column("username", sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column("email", sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column("hashed_password", sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column(
"permissions",
postgresql.JSON(astext_type=sa.Text()),
autoincrement=False,
nullable=False,
),
sa.Column("subscriber", sa.BOOLEAN(), autoincrement=False, nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("users_pkey")),
)
op.create_index(op.f("ix_users_username"), "users", ["username"], unique=True)
op.create_index(op.f("ix_users_id"), "users", ["id"], unique=False)
op.create_index(op.f("ix_users_email"), "users", ["email"], unique=True)
# ### end Alembic commands ###