11"""Initial schema - all tables
22
33Revision ID: 0001
4- Revises:
4+ Revises:
55Create Date: 2026-06-27
66
77"""
8+
89from typing import Sequence , Union
9- from alembic import op
10+
1011import sqlalchemy as sa
12+ from alembic import op
1113
1214revision : str = "0001"
1315down_revision : Union [str , None ] = None
@@ -27,7 +29,13 @@ def upgrade() -> None:
2729 op .create_table (
2830 "query_history" ,
2931 sa .Column ("id" , sa .Integer (), primary_key = True , index = True ),
30- sa .Column ("user_id" , sa .Integer (), sa .ForeignKey ("users.id" ), index = True , nullable = False ),
32+ sa .Column (
33+ "user_id" ,
34+ sa .Integer (),
35+ sa .ForeignKey ("users.id" ),
36+ index = True ,
37+ nullable = False ,
38+ ),
3139 sa .Column ("action" , sa .String (50 ), nullable = False ),
3240 sa .Column ("code" , sa .Text (), nullable = False ),
3341 sa .Column ("result_json" , sa .Text (), nullable = False ),
@@ -36,7 +44,13 @@ def upgrade() -> None:
3644 op .create_table (
3745 "favorite_results" ,
3846 sa .Column ("id" , sa .Integer (), primary_key = True , index = True ),
39- sa .Column ("user_id" , sa .Integer (), sa .ForeignKey ("users.id" ), index = True , nullable = False ),
47+ sa .Column (
48+ "user_id" ,
49+ sa .Integer (),
50+ sa .ForeignKey ("users.id" ),
51+ index = True ,
52+ nullable = False ,
53+ ),
4054 sa .Column ("title" , sa .String (200 ), nullable = False ),
4155 sa .Column ("action" , sa .String (50 ), nullable = False ),
4256 sa .Column ("code" , sa .Text (), nullable = False ),
@@ -48,7 +62,9 @@ def upgrade() -> None:
4862 sa .Column ("id" , sa .Integer (), primary_key = True , index = True ),
4963 sa .Column ("email" , sa .String (320 ), unique = True , index = True , nullable = False ),
5064 sa .Column ("is_active" , sa .Boolean (), nullable = False , default = True ),
51- sa .Column ("unsubscribe_token" , sa .String (64 ), unique = True , index = True , nullable = False ),
65+ sa .Column (
66+ "unsubscribe_token" , sa .String (64 ), unique = True , index = True , nullable = False
67+ ),
5268 sa .Column ("subscribed_at" , sa .DateTime (), nullable = False ),
5369 sa .Column ("last_sent_at" , sa .DateTime (), nullable = True ),
5470 )
@@ -63,7 +79,13 @@ def upgrade() -> None:
6379 op .create_table (
6480 "audit_logs" ,
6581 sa .Column ("id" , sa .Integer (), primary_key = True , index = True ),
66- sa .Column ("actor_id" , sa .Integer (), sa .ForeignKey ("users.id" , ondelete = "SET NULL" ), index = True , nullable = True ),
82+ sa .Column (
83+ "actor_id" ,
84+ sa .Integer (),
85+ sa .ForeignKey ("users.id" , ondelete = "SET NULL" ),
86+ index = True ,
87+ nullable = True ,
88+ ),
6789 sa .Column ("actor_email" , sa .String (320 ), nullable = False ),
6890 sa .Column ("action" , sa .String (100 ), index = True , nullable = False ),
6991 sa .Column ("target_type" , sa .String (50 ), nullable = True ),
0 commit comments