merge: integrate alpha management with main and sequence migration 0005
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
"""scope catalog collections notes and input drafts"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = '0003'
|
||||
down_revision = '0002'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('catalog_scopes',
|
||||
sa.Column('key', sa.String(length=200), nullable=False),
|
||||
sa.Column('scope', sa.JSON(), nullable=False),
|
||||
sa.Column('catalog_version', sa.String(length=36), nullable=True),
|
||||
sa.Column('synced_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.PrimaryKeyConstraint('key')
|
||||
)
|
||||
op.create_table('catalog_batches',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('scope_key', sa.String(length=200), nullable=False),
|
||||
sa.Column('dataset_id', sa.String(length=200), nullable=True),
|
||||
sa.Column('complete', sa.Boolean(), nullable=False),
|
||||
sa.Column('count', sa.Integer(), nullable=False),
|
||||
sa.Column('completed_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.ForeignKeyConstraint(['id'], ['sync_jobs.id'], ),
|
||||
sa.ForeignKeyConstraint(['scope_key'], ['catalog_scopes.key'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_catalog_batches_scope_key'), 'catalog_batches', ['scope_key'], unique=False)
|
||||
op.create_table('catalog_notes',
|
||||
sa.Column('scope_key', sa.String(length=200), nullable=False),
|
||||
sa.Column('dataset_id', sa.String(length=200), nullable=False),
|
||||
sa.Column('field_id', sa.String(length=200), nullable=False),
|
||||
sa.Column('note', sa.Text(), nullable=False),
|
||||
sa.Column('version', sa.Integer(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(['scope_key'], ['catalog_scopes.key'], ),
|
||||
sa.PrimaryKeyConstraint('scope_key', 'dataset_id', 'field_id')
|
||||
)
|
||||
op.create_table('catalog_datasets',
|
||||
sa.Column('scope_key', sa.String(length=200), nullable=False),
|
||||
sa.Column('id', sa.String(length=200), nullable=False),
|
||||
sa.Column('field_version', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['field_version'], ['catalog_batches.id'], ),
|
||||
sa.ForeignKeyConstraint(['scope_key'], ['catalog_scopes.key'], ),
|
||||
sa.PrimaryKeyConstraint('scope_key', 'id')
|
||||
)
|
||||
op.create_table('catalog_entries',
|
||||
sa.Column('batch_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('id', sa.String(length=200), nullable=False),
|
||||
sa.Column('name', sa.Text(), nullable=True),
|
||||
sa.Column('category', sa.String(length=200), nullable=True),
|
||||
sa.Column('subcategory', sa.String(length=200), nullable=True),
|
||||
sa.Column('field_type', sa.String(length=100), nullable=True),
|
||||
sa.Column('coverage', sa.Float(), nullable=True),
|
||||
sa.Column('user_count', sa.Integer(), nullable=True),
|
||||
sa.Column('alpha_count', sa.Integer(), nullable=True),
|
||||
sa.Column('field_count', sa.Integer(), nullable=True),
|
||||
sa.Column('description', sa.Text(), nullable=True),
|
||||
sa.Column('unit', sa.Text(), nullable=True),
|
||||
sa.Column('synced_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(['batch_id'], ['catalog_batches.id'], ),
|
||||
sa.PrimaryKeyConstraint('batch_id', 'id')
|
||||
)
|
||||
op.create_table('template_inputs',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('scope_key', sa.String(length=200), nullable=False),
|
||||
sa.Column('dataset_id', sa.String(length=200), nullable=False),
|
||||
sa.Column('collection_version', sa.String(length=36), nullable=False),
|
||||
sa.Column('selection', sa.String(length=20), nullable=False),
|
||||
sa.Column('field_ids', sa.JSON(), nullable=False),
|
||||
sa.Column('field_types', sa.JSON(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(['collection_version'], ['catalog_batches.id'], ),
|
||||
sa.ForeignKeyConstraint(['scope_key'], ['catalog_scopes.key'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_template_inputs_scope_key'), 'template_inputs', ['scope_key'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_template_inputs_scope_key'), table_name='template_inputs')
|
||||
op.drop_table('template_inputs')
|
||||
op.drop_table('catalog_entries')
|
||||
op.drop_table('catalog_datasets')
|
||||
op.drop_table('catalog_notes')
|
||||
op.drop_index(op.f('ix_catalog_batches_scope_key'), table_name='catalog_batches')
|
||||
op.drop_table('catalog_batches')
|
||||
op.drop_table('catalog_scopes')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,186 @@
|
||||
"""durable worldquant backtests"""
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision = "0004"
|
||||
down_revision = "0003"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"backtest_config",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("concurrency", sa.Integer(), nullable=False),
|
||||
sa.Column("batch_size", sa.Integer(), nullable=False),
|
||||
sa.Column("version", sa.Integer(), nullable=False),
|
||||
sa.Column("blocked_reason", sa.Text(), nullable=True),
|
||||
sa.Column("blocked_until", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_table(
|
||||
"backtest_drafts",
|
||||
sa.Column("id", sa.String(length=36), nullable=False),
|
||||
sa.Column("version", sa.Integer(), nullable=False),
|
||||
sa.Column("name", sa.String(length=200), nullable=False),
|
||||
sa.Column("source", sa.JSON(), nullable=False),
|
||||
sa.Column("candidates", sa.JSON(), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_table(
|
||||
"backtest_previews",
|
||||
sa.Column("id", sa.String(length=36), nullable=False),
|
||||
sa.Column("version", sa.Integer(), nullable=False),
|
||||
sa.Column("name", sa.String(length=200), nullable=False),
|
||||
sa.Column("source", sa.JSON(), nullable=False),
|
||||
sa.Column("candidates", sa.JSON(), nullable=False),
|
||||
sa.Column("batches", sa.JSON(), nullable=False),
|
||||
sa.Column("batch_size", sa.Integer(), nullable=False),
|
||||
sa.Column("digest", sa.String(length=64), nullable=False),
|
||||
sa.Column("duplicates", sa.JSON(), nullable=False),
|
||||
sa.Column("ai_context", sa.JSON(), nullable=False),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_table(
|
||||
"backtest_runs",
|
||||
sa.Column("id", sa.String(length=36), nullable=False),
|
||||
sa.Column("preview_id", sa.String(length=36), nullable=False),
|
||||
sa.Column("idempotency_key", sa.String(length=100), nullable=False),
|
||||
sa.Column("name", sa.String(length=200), nullable=False),
|
||||
sa.Column("source", sa.JSON(), nullable=False),
|
||||
sa.Column("ai_context", sa.JSON(), nullable=False),
|
||||
sa.Column("control", sa.String(length=20), nullable=False),
|
||||
sa.Column("status", sa.String(length=30), nullable=False),
|
||||
sa.Column("version", sa.Integer(), nullable=False),
|
||||
sa.Column("event_seq", sa.Integer(), nullable=False),
|
||||
sa.Column("total", sa.Integer(), nullable=False),
|
||||
sa.Column("batch_size", sa.Integer(), nullable=False),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["preview_id"],
|
||||
["backtest_previews.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("idempotency_key"),
|
||||
sa.UniqueConstraint("preview_id"),
|
||||
)
|
||||
op.create_index(op.f("ix_backtest_runs_status"), "backtest_runs", ["status"], unique=False)
|
||||
op.create_table(
|
||||
"backtest_events",
|
||||
sa.Column("run_id", sa.String(length=36), nullable=False),
|
||||
sa.Column("seq", sa.Integer(), nullable=False),
|
||||
sa.Column("kind", sa.String(length=50), nullable=False),
|
||||
sa.Column("payload", sa.JSON(), nullable=False),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["run_id"],
|
||||
["backtest_runs.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("run_id", "seq"),
|
||||
)
|
||||
op.create_table(
|
||||
"simulation_attempts",
|
||||
sa.Column("id", sa.String(length=36), nullable=False),
|
||||
sa.Column("run_id", sa.String(length=36), nullable=False),
|
||||
sa.Column("ordinal", sa.Integer(), nullable=False),
|
||||
sa.Column("state", sa.String(length=30), nullable=False),
|
||||
sa.Column("payload", sa.JSON(), nullable=False),
|
||||
sa.Column("progress_url", sa.Text(), nullable=True),
|
||||
sa.Column("remote_complete", sa.Boolean(), nullable=False),
|
||||
sa.Column("children", sa.JSON(), nullable=False),
|
||||
sa.Column("receipts", sa.JSON(), nullable=False),
|
||||
sa.Column("poll_count", sa.Integer(), nullable=False),
|
||||
sa.Column("submit_count", sa.Integer(), nullable=False),
|
||||
sa.Column("next_poll_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("error", sa.Text(), nullable=True),
|
||||
sa.Column("error_code", sa.String(length=50), nullable=True),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["run_id"],
|
||||
["backtest_runs.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("run_id", "ordinal"),
|
||||
)
|
||||
op.create_index(op.f("ix_simulation_attempts_run_id"), "simulation_attempts", ["run_id"], unique=False)
|
||||
op.create_index(op.f("ix_simulation_attempts_state"), "simulation_attempts", ["state"], unique=False)
|
||||
op.create_table(
|
||||
"backtest_items",
|
||||
sa.Column("id", sa.String(length=36), nullable=False),
|
||||
sa.Column("run_id", sa.String(length=36), nullable=False),
|
||||
sa.Column("attempt_id", sa.String(length=36), nullable=False),
|
||||
sa.Column("client_item_id", sa.String(length=100), nullable=False),
|
||||
sa.Column("ordinal", sa.Integer(), nullable=False),
|
||||
sa.Column("expression", sa.Text(), nullable=False),
|
||||
sa.Column("settings", sa.JSON(), nullable=False),
|
||||
sa.Column("fingerprint", sa.String(length=64), nullable=False),
|
||||
sa.Column("platform_status", sa.String(length=30), nullable=False),
|
||||
sa.Column("collection_status", sa.String(length=30), nullable=False),
|
||||
sa.Column("persistence_status", sa.String(length=30), nullable=False),
|
||||
sa.Column("simulation_id", sa.String(length=100), nullable=True),
|
||||
sa.Column("alpha_id", sa.String(length=100), nullable=True),
|
||||
sa.Column("error", sa.Text(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["attempt_id"],
|
||||
["simulation_attempts.id"],
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["run_id"],
|
||||
["backtest_runs.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("run_id", "client_item_id"),
|
||||
)
|
||||
op.create_index(op.f("ix_backtest_items_attempt_id"), "backtest_items", ["attempt_id"], unique=False)
|
||||
op.create_index(op.f("ix_backtest_items_fingerprint"), "backtest_items", ["fingerprint"], unique=False)
|
||||
op.create_index(op.f("ix_backtest_items_run_id"), "backtest_items", ["run_id"], unique=False)
|
||||
op.create_table(
|
||||
"backtest_results",
|
||||
sa.Column("item_id", sa.String(length=36), nullable=False),
|
||||
sa.Column("attempt_id", sa.String(length=36), nullable=False),
|
||||
sa.Column("alpha_id", sa.String(length=100), nullable=False),
|
||||
sa.Column("snapshot", sa.JSON(), nullable=False),
|
||||
sa.Column("observed_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("complete", sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["alpha_id"],
|
||||
["alphas.id"],
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["attempt_id"],
|
||||
["simulation_attempts.id"],
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["item_id"],
|
||||
["backtest_items.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("item_id"),
|
||||
)
|
||||
op.create_index(op.f("ix_backtest_results_alpha_id"), "backtest_results", ["alpha_id"], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f("ix_backtest_results_alpha_id"), table_name="backtest_results")
|
||||
op.drop_table("backtest_results")
|
||||
op.drop_index(op.f("ix_backtest_items_run_id"), table_name="backtest_items")
|
||||
op.drop_index(op.f("ix_backtest_items_fingerprint"), table_name="backtest_items")
|
||||
op.drop_index(op.f("ix_backtest_items_attempt_id"), table_name="backtest_items")
|
||||
op.drop_table("backtest_items")
|
||||
op.drop_index(op.f("ix_simulation_attempts_state"), table_name="simulation_attempts")
|
||||
op.drop_index(op.f("ix_simulation_attempts_run_id"), table_name="simulation_attempts")
|
||||
op.drop_table("simulation_attempts")
|
||||
op.drop_table("backtest_events")
|
||||
op.drop_index(op.f("ix_backtest_runs_status"), table_name="backtest_runs")
|
||||
op.drop_table("backtest_runs")
|
||||
op.drop_table("backtest_previews")
|
||||
op.drop_table("backtest_drafts")
|
||||
op.drop_table("backtest_config")
|
||||
# ### end Alembic commands ###
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = "0003"
|
||||
down_revision = "0002"
|
||||
revision = "0005"
|
||||
down_revision = "0004"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
Reference in New Issue
Block a user