mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 00:07:22 +00:00
437 lines
16 KiB
Python
437 lines
16 KiB
Python
"""empty message
|
|
|
|
Revision ID: bbad7e33a780
|
|
Revises:
|
|
Create Date: 2020-06-24 21:17:25.548159
|
|
|
|
"""
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "bbad7e33a780"
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"adminunitmemberrole",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("name", sa.String(length=80), nullable=True),
|
|
sa.Column("description", sa.String(length=255), nullable=True),
|
|
sa.Column("permissions", sa.UnicodeText(), nullable=True),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("name"),
|
|
)
|
|
op.create_table(
|
|
"adminunitorgrole",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("name", sa.String(length=80), nullable=True),
|
|
sa.Column("description", sa.String(length=255), nullable=True),
|
|
sa.Column("permissions", sa.UnicodeText(), nullable=True),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("name"),
|
|
)
|
|
op.create_table(
|
|
"eventcategory",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("name"),
|
|
)
|
|
op.create_table(
|
|
"orgmemberrole",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("name", sa.String(length=80), nullable=True),
|
|
sa.Column("description", sa.String(length=255), nullable=True),
|
|
sa.Column("permissions", sa.UnicodeText(), nullable=True),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("name"),
|
|
)
|
|
op.create_table(
|
|
"role",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("name", sa.String(length=80), nullable=True),
|
|
sa.Column("description", sa.String(length=255), nullable=True),
|
|
sa.Column("permissions", sa.UnicodeText(), nullable=True),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("name"),
|
|
)
|
|
op.create_table(
|
|
"user",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("email", sa.String(length=255), nullable=True),
|
|
sa.Column("username", sa.String(length=255), nullable=True),
|
|
sa.Column("password", sa.String(length=255), nullable=True),
|
|
sa.Column("last_login_at", sa.DateTime(), nullable=True),
|
|
sa.Column("current_login_at", sa.DateTime(), nullable=True),
|
|
sa.Column("last_login_ip", sa.String(length=100), nullable=True),
|
|
sa.Column("current_login_ip", sa.String(length=100), nullable=True),
|
|
sa.Column("login_count", sa.Integer(), nullable=True),
|
|
sa.Column("active", sa.Boolean(), nullable=True),
|
|
sa.Column("fs_uniquifier", sa.String(length=255), nullable=True),
|
|
sa.Column("confirmed_at", sa.DateTime(), nullable=True),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("email"),
|
|
)
|
|
op.create_table(
|
|
"adminunit",
|
|
sa.Column("created_at", sa.DateTime(), nullable=True),
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("name", sa.Unicode(length=255), nullable=True),
|
|
sa.Column("created_by_id", sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["created_by_id"],
|
|
["user.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("name"),
|
|
)
|
|
op.create_table(
|
|
"image",
|
|
sa.Column("created_at", sa.DateTime(), nullable=True),
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("data", sa.LargeBinary(), nullable=True),
|
|
sa.Column("encoding_format", sa.String(length=80), nullable=True),
|
|
sa.Column("created_by_id", sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["created_by_id"],
|
|
["user.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"location",
|
|
sa.Column("created_at", sa.DateTime(), nullable=True),
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("street", sa.Unicode(length=255), nullable=True),
|
|
sa.Column("postalCode", sa.Unicode(length=255), nullable=True),
|
|
sa.Column("city", sa.Unicode(length=255), nullable=True),
|
|
sa.Column("state", sa.Unicode(length=255), nullable=True),
|
|
sa.Column("country", sa.Unicode(length=255), nullable=True),
|
|
sa.Column("latitude", sa.Numeric(precision=18, scale=16), nullable=True),
|
|
sa.Column("longitude", sa.Numeric(precision=19, scale=16), nullable=True),
|
|
sa.Column("created_by_id", sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["created_by_id"],
|
|
["user.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"roles_users",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("user_id", sa.Integer(), nullable=True),
|
|
sa.Column("role_id", sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["role_id"],
|
|
["role.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["user_id"],
|
|
["user.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"adminunitmember",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("admin_unit_id", sa.Integer(), nullable=False),
|
|
sa.Column("user_id", sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["admin_unit_id"],
|
|
["adminunit.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["user_id"],
|
|
["user.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"eventsuggestion",
|
|
sa.Column("created_at", sa.DateTime(), nullable=True),
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("admin_unit_id", sa.Integer(), nullable=False),
|
|
sa.Column("host_name", sa.Unicode(length=255), nullable=False),
|
|
sa.Column("event_name", sa.Unicode(length=255), nullable=False),
|
|
sa.Column("description", sa.UnicodeText(), nullable=False),
|
|
sa.Column("place_name", sa.Unicode(length=255), nullable=False),
|
|
sa.Column("place_street", sa.Unicode(length=255), nullable=True),
|
|
sa.Column("place_postalCode", sa.Unicode(length=255), nullable=False),
|
|
sa.Column("place_city", sa.Unicode(length=255), nullable=False),
|
|
sa.Column("contact_name", sa.Unicode(length=255), nullable=False),
|
|
sa.Column("contact_email", sa.Unicode(length=255), nullable=False),
|
|
sa.Column("external_link", sa.String(length=255), nullable=True),
|
|
sa.Column("created_by_id", sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["admin_unit_id"],
|
|
["adminunit.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["created_by_id"],
|
|
["user.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"organization",
|
|
sa.Column("created_at", sa.DateTime(), nullable=True),
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("name", sa.Unicode(length=255), nullable=True),
|
|
sa.Column("legal_name", sa.Unicode(length=255), nullable=True),
|
|
sa.Column("location_id", sa.Integer(), nullable=True),
|
|
sa.Column("logo_id", sa.Integer(), nullable=True),
|
|
sa.Column("url", sa.String(length=255), nullable=True),
|
|
sa.Column("created_by_id", sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["created_by_id"],
|
|
["user.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["location_id"],
|
|
["location.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["logo_id"],
|
|
["image.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("name"),
|
|
)
|
|
op.create_table(
|
|
"place",
|
|
sa.Column("created_at", sa.DateTime(), nullable=True),
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
|
sa.Column("location_id", sa.Integer(), nullable=True),
|
|
sa.Column("photo_id", sa.Integer(), nullable=True),
|
|
sa.Column("url", sa.String(length=255), nullable=True),
|
|
sa.Column("description", sa.UnicodeText(), nullable=True),
|
|
sa.Column("created_by_id", sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["created_by_id"],
|
|
["user.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["location_id"],
|
|
["location.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["photo_id"],
|
|
["image.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("name"),
|
|
)
|
|
op.create_table(
|
|
"actor",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("user_id", sa.Integer(), nullable=False),
|
|
sa.Column("organization_id", sa.Integer(), nullable=True),
|
|
sa.Column("admin_unit_id", sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["admin_unit_id"],
|
|
["adminunit.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["organization_id"],
|
|
["organization.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["user_id"],
|
|
["user.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("user_id", "organization_id", "admin_unit_id"),
|
|
)
|
|
op.create_table(
|
|
"adminunitmemberroles_members",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("member_id", sa.Integer(), nullable=True),
|
|
sa.Column("role_id", sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["member_id"],
|
|
["adminunitmember.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["role_id"],
|
|
["adminunitmemberrole.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"adminunitorg",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("admin_unit_id", sa.Integer(), nullable=False),
|
|
sa.Column("organization_id", sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["admin_unit_id"],
|
|
["adminunit.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["organization_id"],
|
|
["organization.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"eventsuggestiondate",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("event_suggestion_id", sa.Integer(), nullable=False),
|
|
sa.Column("start", sa.DateTime(timezone=True), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["event_suggestion_id"],
|
|
["eventsuggestion.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"org_or_adminunit",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("organization_id", sa.Integer(), nullable=True),
|
|
sa.Column("admin_unit_id", sa.Integer(), nullable=True),
|
|
sa.CheckConstraint("NOT(organization_id IS NULL AND admin_unit_id IS NULL)"),
|
|
sa.ForeignKeyConstraint(
|
|
["admin_unit_id"],
|
|
["adminunit.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["organization_id"],
|
|
["organization.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("organization_id", "admin_unit_id"),
|
|
)
|
|
op.create_table(
|
|
"orgmember",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("organization_id", sa.Integer(), nullable=False),
|
|
sa.Column("user_id", sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["organization_id"],
|
|
["organization.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["user_id"],
|
|
["user.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"adminunitorgroles_organizations",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("admin_unit_org_id", sa.Integer(), nullable=True),
|
|
sa.Column("role_id", sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["admin_unit_org_id"],
|
|
["adminunitorg.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["role_id"],
|
|
["adminunitorgrole.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"event",
|
|
sa.Column("created_at", sa.DateTime(), nullable=True),
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("admin_unit_id", sa.Integer(), nullable=False),
|
|
sa.Column("host_id", sa.Integer(), nullable=False),
|
|
sa.Column("place_id", sa.Integer(), nullable=False),
|
|
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
|
sa.Column("description", sa.UnicodeText(), nullable=False),
|
|
sa.Column("external_link", sa.String(length=255), nullable=True),
|
|
sa.Column("ticket_link", sa.String(length=255), nullable=True),
|
|
sa.Column("verified", sa.Boolean(), nullable=True),
|
|
sa.Column("photo_id", sa.Integer(), nullable=True),
|
|
sa.Column("category_id", sa.Integer(), nullable=False),
|
|
sa.Column("recurrence_rule", sa.UnicodeText(), nullable=True),
|
|
sa.Column("created_by_id", sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["admin_unit_id"],
|
|
["adminunit.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["category_id"],
|
|
["eventcategory.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["created_by_id"],
|
|
["user.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["host_id"],
|
|
["org_or_adminunit.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["photo_id"],
|
|
["image.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["place_id"],
|
|
["place.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"orgmemberroles_members",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("member_id", sa.Integer(), nullable=True),
|
|
sa.Column("role_id", sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["member_id"],
|
|
["orgmember.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["role_id"],
|
|
["orgmemberrole.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"eventdate",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("event_id", sa.Integer(), nullable=False),
|
|
sa.Column("start", sa.DateTime(timezone=True), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["event_id"],
|
|
["event.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table("eventdate")
|
|
op.drop_table("orgmemberroles_members")
|
|
op.drop_table("event")
|
|
op.drop_table("adminunitorgroles_organizations")
|
|
op.drop_table("orgmember")
|
|
op.drop_table("org_or_adminunit")
|
|
op.drop_table("eventsuggestiondate")
|
|
op.drop_table("adminunitorg")
|
|
op.drop_table("adminunitmemberroles_members")
|
|
op.drop_table("actor")
|
|
op.drop_table("place")
|
|
op.drop_table("organization")
|
|
op.drop_table("eventsuggestion")
|
|
op.drop_table("adminunitmember")
|
|
op.drop_table("roles_users")
|
|
op.drop_table("location")
|
|
op.drop_table("image")
|
|
op.drop_table("adminunit")
|
|
op.drop_table("user")
|
|
op.drop_table("role")
|
|
op.drop_table("orgmemberrole")
|
|
op.drop_table("eventcategory")
|
|
op.drop_table("adminunitorgrole")
|
|
op.drop_table("adminunitmemberrole")
|
|
# ### end Alembic commands ###
|