Skip to content

Commit 89e82d1

Browse files
committed
solve alembic can not find model in scrapy project
1 parent 06f0b67 commit 89e82d1

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""empty message
2+
3+
Revision ID: 07f1446c9aab
4+
Revises: 8882c6147280
5+
Create Date: 2025-12-28 16:49:51.641198
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '07f1446c9aab'
14+
down_revision = '8882c6147280'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.create_table('author',
22+
sa.Column('name', sa.String(length=128), nullable=False),
23+
sa.Column('id', sa.BigInteger(), nullable=False),
24+
sa.Column('create_time', sa.DateTime(), nullable=True, comment='创建时间'),
25+
sa.Column('update_time', sa.DateTime(), nullable=True, comment='更新时间'),
26+
sa.PrimaryKeyConstraint('id')
27+
)
28+
op.create_table('book',
29+
sa.Column('title', sa.String(length=100), nullable=False),
30+
sa.Column('isbn', sa.String(length=20), nullable=True),
31+
sa.Column('price', sa.Numeric(), nullable=True),
32+
sa.Column('description', sa.Text(), nullable=True),
33+
sa.Column('url', sa.String(length=200), nullable=True),
34+
sa.Column('id', sa.BigInteger(), nullable=False),
35+
sa.Column('create_time', sa.DateTime(), nullable=True, comment='创建时间'),
36+
sa.Column('update_time', sa.DateTime(), nullable=True, comment='更新时间'),
37+
sa.PrimaryKeyConstraint('id'),
38+
sa.UniqueConstraint('isbn')
39+
)
40+
op.create_table('book_author',
41+
sa.Column('book_id', sa.BigInteger(), nullable=False),
42+
sa.Column('author_id', sa.BigInteger(), nullable=False),
43+
sa.ForeignKeyConstraint(['author_id'], ['author.id'], ),
44+
sa.ForeignKeyConstraint(['book_id'], ['book.id'], ),
45+
sa.PrimaryKeyConstraint('book_id', 'author_id')
46+
)
47+
# ### end Alembic commands ###
48+
49+
50+
def downgrade():
51+
# ### commands auto generated by Alembic - please adjust! ###
52+
op.drop_table('book_author')
53+
op.drop_table('book')
54+
op.drop_table('author')
55+
# ### end Alembic commands ###
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# @Filename: __init__.py
22
# @Author: codists
33
# @Created: 2025-07-14 23:04:11
4+
5+
# 因为 Book 模型实在另外一个项目 booksbot 用,alembic 检测不到,所以导入到这里,让 alembic 检测到
6+
from .user import User
7+
from .book import Book

0 commit comments

Comments
 (0)