
- Complete FastAPI application with authentication and JWT tokens - SQLite database with SQLAlchemy ORM and Alembic migrations - User management with profile features and search functionality - LinkedIn-style networking with connection requests and acceptance - Social features: posts, likes, comments, announcements, prayer requests - Event management with registration system and capacity limits - RESTful API endpoints for all features with proper authorization - Comprehensive documentation and setup instructions Key Features: - JWT-based authentication with bcrypt password hashing - User profiles with bio, position, contact information - Connection system for church member networking - Community feed with post interactions - Event creation, registration, and attendance tracking - Admin role-based permissions - Health check endpoint and API documentation Environment Variables Required: - SECRET_KEY: JWT secret key for token generation
187 lines
6.8 KiB
Python
187 lines
6.8 KiB
Python
"""Initial migration
|
|
|
|
Revision ID: 001
|
|
Revises:
|
|
Create Date: 2025-07-01 12:00:00.000000
|
|
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "001"
|
|
down_revision: Union[str, None] = None
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Create users table
|
|
op.create_table(
|
|
"users",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("email", sa.String(), nullable=False),
|
|
sa.Column("first_name", sa.String(), nullable=False),
|
|
sa.Column("last_name", sa.String(), nullable=False),
|
|
sa.Column("hashed_password", sa.String(), nullable=False),
|
|
sa.Column("is_active", sa.Boolean(), nullable=True),
|
|
sa.Column("is_admin", sa.Boolean(), nullable=True),
|
|
sa.Column("profile_picture", sa.String(), nullable=True),
|
|
sa.Column("bio", sa.Text(), nullable=True),
|
|
sa.Column("position", sa.String(), nullable=True),
|
|
sa.Column("phone", sa.String(), nullable=True),
|
|
sa.Column("address", sa.Text(), nullable=True),
|
|
sa.Column("date_joined", sa.DateTime(), nullable=False),
|
|
sa.Column("last_login", sa.DateTime(), nullable=True),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(op.f("ix_users_email"), "users", ["email"], unique=True)
|
|
op.create_index(op.f("ix_users_id"), "users", ["id"], unique=False)
|
|
|
|
# Create connections table
|
|
op.create_table(
|
|
"connections",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("sender_id", sa.Integer(), nullable=False),
|
|
sa.Column("receiver_id", sa.Integer(), nullable=False),
|
|
sa.Column("status", sa.String(), nullable=True),
|
|
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["receiver_id"],
|
|
["users.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["sender_id"],
|
|
["users.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(op.f("ix_connections_id"), "connections", ["id"], unique=False)
|
|
|
|
# Create posts table
|
|
op.create_table(
|
|
"posts",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("author_id", sa.Integer(), nullable=False),
|
|
sa.Column("title", sa.String(), nullable=False),
|
|
sa.Column("content", sa.Text(), nullable=False),
|
|
sa.Column("image_url", sa.String(), nullable=True),
|
|
sa.Column("is_announcement", sa.Boolean(), nullable=True),
|
|
sa.Column("is_prayer_request", sa.Boolean(), nullable=True),
|
|
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_posts_id"), "posts", ["id"], unique=False)
|
|
|
|
# Create events table
|
|
op.create_table(
|
|
"events",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("title", sa.String(), nullable=False),
|
|
sa.Column("description", sa.Text(), nullable=True),
|
|
sa.Column("location", sa.String(), nullable=True),
|
|
sa.Column("start_date", sa.DateTime(), nullable=False),
|
|
sa.Column("end_date", sa.DateTime(), nullable=True),
|
|
sa.Column("max_attendees", sa.Integer(), nullable=True),
|
|
sa.Column("is_public", sa.Boolean(), nullable=True),
|
|
sa.Column("image_url", sa.String(), nullable=True),
|
|
sa.Column("created_by", sa.Integer(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["created_by"],
|
|
["users.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(op.f("ix_events_id"), "events", ["id"], unique=False)
|
|
|
|
# Create comments table
|
|
op.create_table(
|
|
"comments",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("post_id", sa.Integer(), nullable=False),
|
|
sa.Column("author_id", sa.Integer(), nullable=False),
|
|
sa.Column("content", sa.Text(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["author_id"],
|
|
["users.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["post_id"],
|
|
["posts.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(op.f("ix_comments_id"), "comments", ["id"], unique=False)
|
|
|
|
# Create likes table
|
|
op.create_table(
|
|
"likes",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("post_id", sa.Integer(), nullable=False),
|
|
sa.Column("user_id", sa.Integer(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["post_id"],
|
|
["posts.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["user_id"],
|
|
["users.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(op.f("ix_likes_id"), "likes", ["id"], unique=False)
|
|
|
|
# Create event_registrations table
|
|
op.create_table(
|
|
"event_registrations",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("event_id", sa.Integer(), nullable=False),
|
|
sa.Column("user_id", sa.Integer(), nullable=False),
|
|
sa.Column("status", sa.String(), nullable=True),
|
|
sa.Column("registered_at", sa.DateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["event_id"],
|
|
["events.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["user_id"],
|
|
["users.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(
|
|
op.f("ix_event_registrations_id"), "event_registrations", ["id"], unique=False
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index(op.f("ix_event_registrations_id"), table_name="event_registrations")
|
|
op.drop_table("event_registrations")
|
|
op.drop_index(op.f("ix_likes_id"), table_name="likes")
|
|
op.drop_table("likes")
|
|
op.drop_index(op.f("ix_comments_id"), table_name="comments")
|
|
op.drop_table("comments")
|
|
op.drop_index(op.f("ix_events_id"), table_name="events")
|
|
op.drop_table("events")
|
|
op.drop_index(op.f("ix_posts_id"), table_name="posts")
|
|
op.drop_table("posts")
|
|
op.drop_index(op.f("ix_connections_id"), table_name="connections")
|
|
op.drop_table("connections")
|
|
op.drop_index(op.f("ix_users_id"), table_name="users")
|
|
op.drop_index(op.f("ix_users_email"), table_name="users")
|
|
op.drop_table("users")
|