mirror of
https://github.com/lorsanstand/Aether.git
synced 2026-06-19 20:15:16 +03:00
Add websckets connection
This commit is contained in:
@@ -9,6 +9,8 @@ from alembic import context
|
||||
|
||||
from app.core.database import Base
|
||||
from app.core.config import settings
|
||||
from app.users.models import UserModel
|
||||
from app.chats.models import MessageModel, ChatModel, ParticipantModel
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
"""Create tables
|
||||
|
||||
Revision ID: 0d3f7039ba77
|
||||
Revises: 7ad624ae1699
|
||||
Create Date: 2026-01-12 15:51:43.453822
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '0d3f7039ba77'
|
||||
down_revision: Union[str, Sequence[str], None] = '7ad624ae1699'
|
||||
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.create_table('chat',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('is_group', sa.Boolean(), nullable=False),
|
||||
sa.Column('last_message', sa.String(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('chat_pkey'))
|
||||
)
|
||||
op.create_index(op.f('chat_id_idx'), 'chat', ['id'], unique=False)
|
||||
op.create_table('user',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('display_name', sa.String(), nullable=False),
|
||||
sa.Column('username', sa.String(), nullable=False),
|
||||
sa.Column('email', sa.String(), nullable=False),
|
||||
sa.Column('birth_day', sa.DATE(), nullable=True),
|
||||
sa.Column('description', sa.String(), nullable=True),
|
||||
sa.Column('avatar_url', sa.String(), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('is_verified', sa.Boolean(), nullable=False),
|
||||
sa.Column('is_superuser', sa.Boolean(), nullable=False),
|
||||
sa.Column('hashed_password', sa.String(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('user_pkey'))
|
||||
)
|
||||
op.create_index(op.f('user_email_idx'), 'user', ['email'], unique=True)
|
||||
op.create_index(op.f('user_id_idx'), 'user', ['id'], unique=False)
|
||||
op.create_index(op.f('user_username_idx'), 'user', ['username'], unique=True)
|
||||
op.create_table('Participant',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('chat_id', sa.UUID(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.ForeignKeyConstraint(['chat_id'], ['chat.id'], name=op.f('Participant_chat_id_fkey'), ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('Participant_user_id_fkey'), ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('Participant_pkey')),
|
||||
sa.UniqueConstraint('chat_id', 'user_id', name='uq_chat_user')
|
||||
)
|
||||
op.create_index(op.f('Participant_chat_id_idx'), 'Participant', ['chat_id'], unique=False)
|
||||
op.create_index(op.f('Participant_id_idx'), 'Participant', ['id'], unique=False)
|
||||
op.create_index(op.f('Participant_user_id_idx'), 'Participant', ['user_id'], unique=False)
|
||||
op.create_table('message',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('sender_id', sa.Integer(), nullable=False),
|
||||
sa.Column('chat_id', sa.UUID(), nullable=False),
|
||||
sa.Column('content', sa.String(), nullable=False),
|
||||
sa.Column('is_read', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.ForeignKeyConstraint(['chat_id'], ['chat.id'], name=op.f('message_chat_id_fkey'), ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['sender_id'], ['user.id'], name=op.f('message_sender_id_fkey'), ondelete='SET NULL'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('message_pkey'))
|
||||
)
|
||||
op.create_index(op.f('message_chat_id_idx'), 'message', ['chat_id'], unique=False)
|
||||
op.create_index(op.f('message_id_idx'), 'message', ['id'], unique=False)
|
||||
op.create_index(op.f('message_sender_id_idx'), 'message', ['sender_id'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('message_sender_id_idx'), table_name='message')
|
||||
op.drop_index(op.f('message_id_idx'), table_name='message')
|
||||
op.drop_index(op.f('message_chat_id_idx'), table_name='message')
|
||||
op.drop_table('message')
|
||||
op.drop_index(op.f('Participant_user_id_idx'), table_name='Participant')
|
||||
op.drop_index(op.f('Participant_id_idx'), table_name='Participant')
|
||||
op.drop_index(op.f('Participant_chat_id_idx'), table_name='Participant')
|
||||
op.drop_table('Participant')
|
||||
op.drop_index(op.f('user_username_idx'), table_name='user')
|
||||
op.drop_index(op.f('user_id_idx'), table_name='user')
|
||||
op.drop_index(op.f('user_email_idx'), table_name='user')
|
||||
op.drop_table('user')
|
||||
op.drop_index(op.f('chat_id_idx'), table_name='chat')
|
||||
op.drop_table('chat')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,32 @@
|
||||
"""EDIT: chat tables
|
||||
|
||||
Revision ID: 7a5ccb6859fe
|
||||
Revises: fd15ec3ae3fb
|
||||
Create Date: 2026-01-12 14:51:11.514074
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '7a5ccb6859fe'
|
||||
down_revision: Union[str, Sequence[str], None] = 'fd15ec3ae3fb'
|
||||
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! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,32 @@
|
||||
"""EDIT: chat tables
|
||||
|
||||
Revision ID: 7ad624ae1699
|
||||
Revises: 7a5ccb6859fe
|
||||
Create Date: 2026-01-12 14:54:04.459361
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '7ad624ae1699'
|
||||
down_revision: Union[str, Sequence[str], None] = '7a5ccb6859fe'
|
||||
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! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,53 @@
|
||||
"""ADD: chat tables
|
||||
|
||||
Revision ID: fd15ec3ae3fb
|
||||
Revises: 4d00c9b0516e
|
||||
Create Date: 2026-01-11 21:54:51.418126
|
||||
|
||||
"""
|
||||
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 = 'fd15ec3ae3fb'
|
||||
down_revision: Union[str, Sequence[str], None] = '4d00c9b0516e'
|
||||
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('user_email_idx'), table_name='user')
|
||||
op.drop_index(op.f('user_id_idx'), table_name='user')
|
||||
op.drop_index(op.f('user_username_idx'), table_name='user')
|
||||
op.drop_table('user')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('user',
|
||||
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('display_name', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('username', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('email', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('birth_day', sa.DATE(), autoincrement=False, nullable=True),
|
||||
sa.Column('description', sa.VARCHAR(), autoincrement=False, nullable=True),
|
||||
sa.Column('avatar_url', sa.VARCHAR(), autoincrement=False, nullable=True),
|
||||
sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_verified', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_superuser', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('created_at', postgresql.TIMESTAMP(), server_default=sa.text('now()'), autoincrement=False, nullable=False),
|
||||
sa.Column('updated_at', postgresql.TIMESTAMP(), server_default=sa.text('now()'), autoincrement=False, nullable=False),
|
||||
sa.Column('hashed_password', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('user_pkey'))
|
||||
)
|
||||
op.create_index(op.f('user_username_idx'), 'user', ['username'], unique=True)
|
||||
op.create_index(op.f('user_id_idx'), 'user', ['id'], unique=False)
|
||||
op.create_index(op.f('user_email_idx'), 'user', ['email'], unique=True)
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user