add events
This commit is contained in:
parent
7a5312c607
commit
f11c18f012
3 changed files with 164 additions and 6 deletions
|
|
@ -11,7 +11,6 @@ from typing import Sequence, Union
|
|||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlalchemy.dialects.postgresql as psql
|
||||
import uuid
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "abfbb3d96037"
|
||||
|
|
@ -22,16 +21,29 @@ depends_on: Union[str, Sequence[str], None] = None
|
|||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
|
||||
op.execute("CREATE EXTENSION IF NOT EXISTS pgcrypto;")
|
||||
|
||||
op.create_table(
|
||||
"user_event_table",
|
||||
sa.Column("id", sa.UUID(as_uuid=True), nullable=False, default=uuid.uuid4),
|
||||
sa.Column("sequence", sa.Integer(), nullable=False),
|
||||
"user_events",
|
||||
sa.Column(
|
||||
"id",
|
||||
sa.UUID(as_uuid=True),
|
||||
nullable=False,
|
||||
server_default=sa.text("gen_random_uuid()"),
|
||||
),
|
||||
sa.Column("sequence", sa.Integer(), nullable=False, autoincrement=True),
|
||||
sa.Column("event_payload", psql.JSONB, nullable=False),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
nullable=False,
|
||||
server_default=sa.text("NOW()"),
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id", "sequence"),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
op.drop_table("user_event_table")
|
||||
op.drop_table("user_event")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue