40a327b3debd_create_initial_migrations.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. """Create initial migrations
  2. Revision ID: 40a327b3debd
  3. Revises:
  4. Create Date: 2024-02-18 15:29:19.409064
  5. """
  6. from typing import Sequence, Union
  7. import sqlalchemy as sa
  8. from alembic import op
  9. # revision identifiers, used by Alembic.
  10. revision: str = "40a327b3debd"
  11. down_revision: Union[str, None] = None
  12. branch_labels: Union[str, Sequence[str], None] = None
  13. depends_on: Union[str, Sequence[str], None] = None
  14. def upgrade() -> None:
  15. # ### commands auto generated by Alembic - please adjust! ###
  16. op.create_table(
  17. "ec_chat_history",
  18. sa.Column("app_id", sa.String(), nullable=False),
  19. sa.Column("id", sa.String(), nullable=False),
  20. sa.Column("session_id", sa.String(), nullable=False),
  21. sa.Column("question", sa.Text(), nullable=True),
  22. sa.Column("answer", sa.Text(), nullable=True),
  23. sa.Column("metadata", sa.Text(), nullable=True),
  24. sa.Column("created_at", sa.TIMESTAMP(), nullable=True),
  25. sa.PrimaryKeyConstraint("app_id", "id", "session_id"),
  26. )
  27. op.create_index(op.f("ix_ec_chat_history_created_at"), "ec_chat_history", ["created_at"], unique=False)
  28. op.create_index(op.f("ix_ec_chat_history_session_id"), "ec_chat_history", ["session_id"], unique=False)
  29. op.create_table(
  30. "ec_data_sources",
  31. sa.Column("id", sa.String(), nullable=False),
  32. sa.Column("app_id", sa.Text(), nullable=True),
  33. sa.Column("hash", sa.Text(), nullable=True),
  34. sa.Column("type", sa.Text(), nullable=True),
  35. sa.Column("value", sa.Text(), nullable=True),
  36. sa.Column("metadata", sa.Text(), nullable=True),
  37. sa.Column("is_uploaded", sa.Integer(), nullable=True),
  38. sa.PrimaryKeyConstraint("id"),
  39. )
  40. op.create_index(op.f("ix_ec_data_sources_hash"), "ec_data_sources", ["hash"], unique=False)
  41. op.create_index(op.f("ix_ec_data_sources_app_id"), "ec_data_sources", ["app_id"], unique=False)
  42. op.create_index(op.f("ix_ec_data_sources_type"), "ec_data_sources", ["type"], unique=False)
  43. # ### end Alembic commands ###
  44. def downgrade() -> None:
  45. # ### commands auto generated by Alembic - please adjust! ###
  46. op.drop_index(op.f("ix_ec_data_sources_type"), table_name="ec_data_sources")
  47. op.drop_index(op.f("ix_ec_data_sources_app_id"), table_name="ec_data_sources")
  48. op.drop_index(op.f("ix_ec_data_sources_hash"), table_name="ec_data_sources")
  49. op.drop_table("ec_data_sources")
  50. op.drop_index(op.f("ix_ec_chat_history_session_id"), table_name="ec_chat_history")
  51. op.drop_index(op.f("ix_ec_chat_history_created_at"), table_name="ec_chat_history")
  52. op.drop_table("ec_chat_history")
  53. # ### end Alembic commands ###