Devices have replaced Clients for authentication as well as location using sections.
Printing of reports done. Main section is now a fixture User and Devices list gives last login details.
This commit is contained in:
91
barker/alembic/versions/00878740057e_devices.py
Normal file
91
barker/alembic/versions/00878740057e_devices.py
Normal file
@ -0,0 +1,91 @@
|
||||
"""devices
|
||||
|
||||
Revision ID: 00878740057e
|
||||
Revises: 8c06ac60d125
|
||||
Create Date: 2020-10-27 14:02:39.859733
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy import column, table
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "00878740057e"
|
||||
down_revision = "8c06ac60d125"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"login_history",
|
||||
sa.Column("login_history_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("device_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("date", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(["device_id"], ["devices.id"], name=op.f("fk_login_history_device_id_devices")),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], name=op.f("fk_login_history_user_id_users")),
|
||||
sa.PrimaryKeyConstraint("login_history_id", name=op.f("pk_login_history")),
|
||||
sa.UniqueConstraint("user_id", "device_id", "date", name=op.f("uq_login_history_user_id")),
|
||||
)
|
||||
op.drop_table("clients")
|
||||
op.add_column("devices", sa.Column("enabled", sa.Boolean(), nullable=False))
|
||||
op.add_column("devices", sa.Column("creation_date", sa.DateTime(timezone=True), nullable=False))
|
||||
op.alter_column("food_tables", "seats", existing_type=sa.NUMERIC(), type_=sa.Integer(), existing_nullable=False)
|
||||
op.alter_column(
|
||||
"food_tables", "sort_order", existing_type=sa.NUMERIC(), type_=sa.Integer(), existing_nullable=False
|
||||
)
|
||||
op.alter_column(
|
||||
"menu_categories", "sort_order", existing_type=sa.NUMERIC(), type_=sa.Integer(), existing_nullable=False
|
||||
)
|
||||
op.alter_column(
|
||||
"modifier_categories", "sort_order", existing_type=sa.NUMERIC(), type_=sa.Integer(), existing_nullable=False
|
||||
)
|
||||
op.alter_column("products", "sort_order", existing_type=sa.NUMERIC(), type_=sa.Integer(), existing_nullable=False)
|
||||
op.add_column("sections", sa.Column("is_fixture", sa.Boolean(), nullable=True))
|
||||
section = table("sections", column("id", postgresql.UUID(as_uuid=True)), column("is_fixture", sa.Boolean()))
|
||||
op.execute(
|
||||
section.update()
|
||||
.where(section.c.id == op.inline_literal("3f13f6e7-dc76-4fca-8fdb-b2bbf29b35df"))
|
||||
.values({"is_fixture": op.inline_literal(True)})
|
||||
)
|
||||
op.execute(
|
||||
section.update()
|
||||
.where(section.c.id != op.inline_literal("3f13f6e7-dc76-4fca-8fdb-b2bbf29b35df"))
|
||||
.values({"is_fixture": op.inline_literal(False)})
|
||||
)
|
||||
op.alter_column("sections", "is_fixture", nullable=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column("sections", "is_fixture")
|
||||
op.alter_column("products", "sort_order", existing_type=sa.Integer(), type_=sa.NUMERIC(), existing_nullable=False)
|
||||
op.alter_column(
|
||||
"modifier_categories", "sort_order", existing_type=sa.Integer(), type_=sa.NUMERIC(), existing_nullable=False
|
||||
)
|
||||
op.alter_column(
|
||||
"menu_categories", "sort_order", existing_type=sa.Integer(), type_=sa.NUMERIC(), existing_nullable=False
|
||||
)
|
||||
op.alter_column(
|
||||
"food_tables", "sort_order", existing_type=sa.Integer(), type_=sa.NUMERIC(), existing_nullable=False
|
||||
)
|
||||
op.alter_column("food_tables", "seats", existing_type=sa.Integer(), type_=sa.NUMERIC(), existing_nullable=False)
|
||||
op.drop_column("devices", "enabled")
|
||||
op.create_table(
|
||||
"clients",
|
||||
sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column("name", sa.VARCHAR(length=255), autoincrement=False, nullable=False),
|
||||
sa.Column("enabled", sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column("otp", sa.INTEGER(), autoincrement=False, nullable=True),
|
||||
sa.Column("creation_date", postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name="pk_clients"),
|
||||
sa.UniqueConstraint("name", name="uq_clients_name"),
|
||||
)
|
||||
op.drop_table("login_history")
|
||||
# ### end Alembic commands ###
|
||||
@ -466,6 +466,8 @@ def upgrade():
|
||||
op.execute(Permission.__table__.insert().values(id="5b66c6f6-003a-4ef8-ba28-49b8ff1ac33c", name="Printers"))
|
||||
op.execute(Permission.__table__.insert().values(id="c973f32c-a37b-496a-8dc5-60d2e4c39e97", name="Sections"))
|
||||
op.execute(Permission.__table__.insert().values(id="7a04ba63-5d08-4078-9051-a6d91cce3e48", name="Section Printers"))
|
||||
op.execute(Permission.__table__.insert().values(id="d4e1d14f-f2c2-4728-9303-a0d8c74c5ea1", name="Devices"))
|
||||
op.execute(Permission.__table__.insert().values(id="5f6110ba-2d3a-41cb-9597-1157774f10cb", name="Add Devices"))
|
||||
op.execute(Section.__table__.insert().values(id="3f13f6e7-dc76-4fca-8fdb-b2bbf29b35df", name="Main"))
|
||||
|
||||
op.execute(
|
||||
|
||||
Reference in New Issue
Block a user