init: 初始化项目
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"""Add selected_text to generation_points
|
||||
|
||||
Revision ID: 011bde04d871
|
||||
Revises: 857f5a3874dd
|
||||
Create Date: 2026-07-06 18:19:15.771438
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision: str = '011bde04d871'
|
||||
down_revision: Union[str, None] = '857f5a3874dd'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('generation_points', sa.Column('selected_text', sa.Text(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('generation_points', 'selected_text')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,88 @@
|
||||
"""Initial schema
|
||||
|
||||
Revision ID: 857f5a3874dd
|
||||
Revises:
|
||||
Create Date: 2026-07-06 16:42:37.845634
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision: str = '857f5a3874dd'
|
||||
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:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('models',
|
||||
sa.Column('name', sa.String(length=100), nullable=False),
|
||||
sa.Column('provider', sa.String(length=50), nullable=False),
|
||||
sa.Column('endpoint', sa.String(length=255), nullable=False),
|
||||
sa.Column('api_key', sa.Text(), nullable=False),
|
||||
sa.Column('extra_params', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
|
||||
sa.Column('is_enabled', sa.Boolean(), nullable=False),
|
||||
sa.Column('remark', sa.Text(), nullable=True),
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('system_config',
|
||||
sa.Column('key', sa.String(length=50), nullable=False),
|
||||
sa.Column('value', sa.Text(), nullable=True),
|
||||
sa.Column('description', sa.String(length=200), nullable=True),
|
||||
sa.PrimaryKeyConstraint('key')
|
||||
)
|
||||
op.create_table('templates',
|
||||
sa.Column('name', sa.String(length=200), nullable=False),
|
||||
sa.Column('file_path', sa.String(length=500), nullable=False),
|
||||
sa.Column('html_content', sa.Text(), nullable=True),
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('generation_points',
|
||||
sa.Column('template_id', sa.UUID(), nullable=False),
|
||||
sa.Column('position', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
|
||||
sa.Column('prompt', sa.Text(), nullable=False),
|
||||
sa.Column('model_id', sa.UUID(), nullable=True),
|
||||
sa.Column('ref_file_path', sa.String(length=500), nullable=True),
|
||||
sa.Column('order', sa.Integer(), nullable=False),
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.ForeignKeyConstraint(['model_id'], ['models.id'], ondelete='SET NULL'),
|
||||
sa.ForeignKeyConstraint(['template_id'], ['templates.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_generation_points_template_id'), 'generation_points', ['template_id'], unique=False)
|
||||
op.create_table('generation_tasks',
|
||||
sa.Column('template_id', sa.UUID(), nullable=False),
|
||||
sa.Column('status', sa.String(length=20), nullable=False),
|
||||
sa.Column('result_file_path', sa.String(length=500), nullable=True),
|
||||
sa.Column('error_msg', sa.Text(), nullable=True),
|
||||
sa.Column('celery_task_id', sa.String(length=100), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('finished_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['template_id'], ['templates.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_generation_tasks_template_id'), 'generation_tasks', ['template_id'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_generation_tasks_template_id'), table_name='generation_tasks')
|
||||
op.drop_table('generation_tasks')
|
||||
op.drop_index(op.f('ix_generation_points_template_id'), table_name='generation_points')
|
||||
op.drop_table('generation_points')
|
||||
op.drop_table('templates')
|
||||
op.drop_table('system_config')
|
||||
op.drop_table('models')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,33 @@
|
||||
"""Change ref_file_path to Text for multi-file support
|
||||
|
||||
Revision ID: 9066ecf60786
|
||||
Revises: b4b91d4466e4
|
||||
Create Date: 2026-07-06 21:01:41.552375
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision: str = '9066ecf60786'
|
||||
down_revision: Union[str, None] = 'b4b91d4466e4'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('generation_points', 'ref_file_path',
|
||||
existing_type=sa.VARCHAR(length=500),
|
||||
type_=sa.Text(),
|
||||
existing_nullable=True)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('generation_points', 'ref_file_path',
|
||||
existing_type=sa.Text(),
|
||||
type_=sa.VARCHAR(length=500),
|
||||
existing_nullable=True)
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,29 @@
|
||||
"""Add need_ref_file and remark to generation_points
|
||||
|
||||
Revision ID: b4b91d4466e4
|
||||
Revises: 011bde04d871
|
||||
Create Date: 2026-07-06 18:27:03.054325
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision: str = 'b4b91d4466e4'
|
||||
down_revision: Union[str, None] = '011bde04d871'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('generation_points', sa.Column('need_ref_file', sa.Boolean(), nullable=False))
|
||||
op.add_column('generation_points', sa.Column('remark', sa.Text(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('generation_points', 'remark')
|
||||
op.drop_column('generation_points', 'need_ref_file')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user