Moved barker one level down and using poetry for setup
This commit is contained in:
24
barker/.env
24
barker/.env
@ -1,24 +0,0 @@
|
||||
HOST=0.0.0.0
|
||||
PORT=6543
|
||||
LOG_LEVEL=WARN
|
||||
DEBUG=true
|
||||
SQLALCHEMY_DATABASE_URI=
|
||||
MODULE_NAME=barker.main
|
||||
PROJECT_NAME=barker
|
||||
POSTGRES_SERVER=
|
||||
POSTGRES_USER=
|
||||
POSTGRES_PASSWORD=
|
||||
POSTGRES_DB=
|
||||
|
||||
# openssl rand -hex 32
|
||||
SECRET_KEY=
|
||||
# openssl rand -hex 5
|
||||
MIDDLEWARE_SECRET_KEY=
|
||||
ALGORITHM=HS256
|
||||
JWT_TOKEN_EXPIRE_MINUTES=30
|
||||
|
||||
NEW_DAY_OFFSET_MINUTES =420
|
||||
TIMEZONE_OFFSET_MINUTES=330
|
||||
|
||||
ALEMBIC_LOG_LEVEL=INFO
|
||||
ALEMBIC_SQLALCHEMY_LOG_LEVEL=WARN
|
||||
85
barker/alembic.ini
Normal file
85
barker/alembic.ini
Normal file
@ -0,0 +1,85 @@
|
||||
# A generic, single database configuration.
|
||||
|
||||
[alembic]
|
||||
# path to migration scripts
|
||||
script_location = alembic
|
||||
|
||||
# template used to generate migration files
|
||||
# file_template = %%(rev)s_%%(slug)s
|
||||
|
||||
# timezone to use when rendering the date
|
||||
# within the migration file as well as the filename.
|
||||
# string value is passed to dateutil.tz.gettz()
|
||||
# leave blank for localtime
|
||||
# timezone =
|
||||
|
||||
# max length of characters to apply to the
|
||||
# "slug" field
|
||||
# truncate_slug_length = 40
|
||||
|
||||
# set to 'true' to run the environment during
|
||||
# the 'revision' command, regardless of autogenerate
|
||||
# revision_environment = false
|
||||
|
||||
# set to 'true' to allow .pyc and .pyo files without
|
||||
# a source .py file to be detected as revisions in the
|
||||
# versions/ directory
|
||||
# sourceless = false
|
||||
|
||||
# version location specification; this defaults
|
||||
# to alembic/versions. When using multiple version
|
||||
# directories, initial revisions must be specified with --version-path
|
||||
# version_locations = %(here)s/bar %(here)s/bat alembic/versions
|
||||
|
||||
# the output encoding used when revision files
|
||||
# are written from script.py.mako
|
||||
# output_encoding = utf-8
|
||||
|
||||
sqlalchemy.url = driver://user:pass@localhost/dbname
|
||||
|
||||
|
||||
[post_write_hooks]
|
||||
# post_write_hooks defines scripts or Python functions that are run
|
||||
# on newly generated revision scripts. See the documentation for further
|
||||
# detail and examples
|
||||
|
||||
# format using "black" - use the console_scripts runner, against the "black" entrypoint
|
||||
# hooks=black
|
||||
# black.type=console_scripts
|
||||
# black.entrypoint=black
|
||||
# black.options=-l 79
|
||||
|
||||
# Logging configuration
|
||||
[loggers]
|
||||
keys = root,sqlalchemy,alembic
|
||||
|
||||
[handlers]
|
||||
keys = console
|
||||
|
||||
[formatters]
|
||||
keys = generic
|
||||
|
||||
[logger_root]
|
||||
level = WARN
|
||||
handlers = console
|
||||
qualname =
|
||||
|
||||
[logger_sqlalchemy]
|
||||
level = WARN
|
||||
handlers =
|
||||
qualname = sqlalchemy.engine
|
||||
|
||||
[logger_alembic]
|
||||
level = INFO
|
||||
handlers =
|
||||
qualname = alembic
|
||||
|
||||
[handler_console]
|
||||
class = StreamHandler
|
||||
args = (sys.stderr,)
|
||||
level = NOTSET
|
||||
formatter = generic
|
||||
|
||||
[formatter_generic]
|
||||
format = %(levelname)-5.5s [%(name)s] %(message)s
|
||||
datefmt = %H:%M:%S
|
||||
1
barker/alembic/README
Normal file
1
barker/alembic/README
Normal file
@ -0,0 +1 @@
|
||||
Generic single-database configuration.
|
||||
70
barker/alembic/env.py
Normal file
70
barker/alembic/env.py
Normal file
@ -0,0 +1,70 @@
|
||||
import logging
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy import pool
|
||||
|
||||
from alembic import context
|
||||
from barker.core.config import settings
|
||||
|
||||
logging.basicConfig()
|
||||
logging.getLogger("sqlalchemy.engine").setLevel(settings.ALEMBIC_LOG_LEVEL)
|
||||
logging.getLogger("alembic").setLevel(settings.ALEMBIC_LOG_LEVEL)
|
||||
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
|
||||
from barker.models.auth import User # noqa
|
||||
|
||||
target_metadata = User.metadata
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
# can be acquired:
|
||||
# my_important_option = config.get_main_option("my_important_option")
|
||||
# ... etc.
|
||||
|
||||
|
||||
def run_migrations_offline():
|
||||
"""Run migrations in 'offline' mode.
|
||||
|
||||
This configures the context with just a URL
|
||||
and not an Engine, though an Engine is acceptable
|
||||
here as well. By skipping the Engine creation
|
||||
we don't even need a DBAPI to be available.
|
||||
|
||||
Calls to context.execute() here emit the given string to the
|
||||
script output.
|
||||
|
||||
"""
|
||||
url = settings.SQLALCHEMY_DATABASE_URI
|
||||
context.configure(
|
||||
url=url,
|
||||
target_metadata=target_metadata,
|
||||
literal_binds=True,
|
||||
dialect_opts={"paramstyle": "named"},
|
||||
compare_type=True,
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
def run_migrations_online():
|
||||
"""Run migrations in 'online' mode.
|
||||
|
||||
In this scenario we need to create an Engine
|
||||
and associate a connection with the context.
|
||||
|
||||
"""
|
||||
connectable = create_engine(settings.SQLALCHEMY_DATABASE_URI, poolclass=pool.NullPool,)
|
||||
|
||||
with connectable.connect() as connection:
|
||||
context.configure(connection=connection, target_metadata=target_metadata, compare_type=True)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
||||
24
barker/alembic/script.py.mako
Normal file
24
barker/alembic/script.py.mako
Normal file
@ -0,0 +1,24 @@
|
||||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = ${repr(up_revision)}
|
||||
down_revision = ${repr(down_revision)}
|
||||
branch_labels = ${repr(branch_labels)}
|
||||
depends_on = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade():
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade():
|
||||
${downgrades if downgrades else "pass"}
|
||||
570
barker/alembic/versions/8c06ac60d125_initial_commit.py
Normal file
570
barker/alembic/versions/8c06ac60d125_initial_commit.py
Normal file
@ -0,0 +1,570 @@
|
||||
"""Initial Commit
|
||||
|
||||
Revision ID: 8c06ac60d125
|
||||
Revises:
|
||||
Create Date: 2020-06-04 08:14:34.132248
|
||||
|
||||
"""
|
||||
import uuid
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
from barker.models import Section, ModifierCategory, SettleOption, Customer, DbSetting
|
||||
from barker.models.auth import User, Permission # noqa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "8c06ac60d125"
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"clients",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("enabled", sa.Boolean(), nullable=False),
|
||||
sa.Column("otp", sa.Integer(), nullable=True),
|
||||
sa.Column("creation_date", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_clients")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_clients_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"customers",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("company", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("phone", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("address", sa.Unicode(length=255), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_customers")),
|
||||
sa.UniqueConstraint("phone", name=op.f("uq_customers_phone")),
|
||||
)
|
||||
op.create_table(
|
||||
"menu_categories",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("discount_limit", sa.Numeric(), nullable=False),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False),
|
||||
sa.Column("is_fixture", sa.Boolean(), nullable=False),
|
||||
sa.Column("sort_order", sa.Numeric(), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_menu_categories")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_menu_categories_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"modifier_categories",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("minimum", sa.Integer(), nullable=False),
|
||||
sa.Column("maximum", sa.Integer(), nullable=True),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False),
|
||||
sa.Column("sort_order", sa.Numeric(), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_modifier_categories")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_modifier_categories_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"permissions",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_permissions")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_permissions_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"printers",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("address", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("cut_code", sa.Unicode(length=255), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_printers")),
|
||||
sa.UniqueConstraint("address", name=op.f("uq_printers_address")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_printers_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"roles",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_roles")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_roles_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"sections",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_sections")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_sections_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"settings",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("data", sa.JSON(), nullable=True),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_settings")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_settings_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"settle_options",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("show_in_choices", sa.Boolean(), nullable=False),
|
||||
sa.Column("display_group", sa.Integer(), nullable=False),
|
||||
sa.Column("is_print", sa.Boolean(), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_settle_options")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_settle_options_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"taxes",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("rate", sa.Numeric(), nullable=False),
|
||||
sa.Column("is_fixture", sa.Boolean(), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_taxes")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_taxes_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"users",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("password", sa.Unicode(length=60), nullable=False),
|
||||
sa.Column("locked_out", sa.Boolean(), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_users")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_users_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"devices",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("section_id", postgresql.UUID(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["section_id"], ["sections.id"], name=op.f("fk_devices_section_id_sections")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_devices")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_devices_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"food_tables",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("seats", sa.Numeric(), nullable=False),
|
||||
sa.Column("section_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False),
|
||||
sa.Column("sort_order", sa.Numeric(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["section_id"], ["sections.id"], name=op.f("fk_food_tables_section_id_sections")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_food_tables")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_food_tables_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"guest_book",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("customer_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("pax", sa.Numeric(), nullable=False),
|
||||
sa.Column("creation_date", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(["customer_id"], ["customers.id"], name=op.f("fk_guest_book_customer_id_customers")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_guest_book")),
|
||||
)
|
||||
op.create_table(
|
||||
"modifiers",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("show_in_bill", sa.Boolean(), nullable=False),
|
||||
sa.Column("price", sa.Numeric(), nullable=False),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False),
|
||||
sa.Column("modifier_category_id", postgresql.UUID(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["modifier_category_id"],
|
||||
["modifier_categories.id"],
|
||||
name=op.f("fk_modifiers_modifier_category_id_modifier_categories"),
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_modifiers")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_modifiers_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"role_permissions",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("permission_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("role_id", postgresql.UUID(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["permission_id"], ["permissions.id"], name=op.f("fk_role_permissions_permission_id_permissions")
|
||||
),
|
||||
sa.ForeignKeyConstraint(["role_id"], ["roles.id"], name=op.f("fk_role_permissions_role_id_roles")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_role_permissions")),
|
||||
sa.UniqueConstraint("permission_id", "role_id", name=op.f("uq_role_permissions_permission_id")),
|
||||
)
|
||||
op.create_table(
|
||||
"sale_categories",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("tax_id", postgresql.UUID(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["tax_id"], ["taxes.id"], name=op.f("fk_sale_categories_tax_id_taxes")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_sale_categories")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_sale_categories_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"section_printers",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("menu_category_id", postgresql.UUID(), nullable=True),
|
||||
sa.Column("section_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("printer_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("copies", sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["menu_category_id"],
|
||||
["menu_categories.id"],
|
||||
name=op.f("fk_section_printers_menu_category_id_menu_categories"),
|
||||
),
|
||||
sa.ForeignKeyConstraint(["printer_id"], ["printers.id"], name=op.f("fk_section_printers_printer_id_printers")),
|
||||
sa.ForeignKeyConstraint(["section_id"], ["sections.id"], name=op.f("fk_section_printers_section_id_sections")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_section_printers")),
|
||||
sa.UniqueConstraint("menu_category_id", "section_id", name=op.f("uq_section_printers_menu_category_id")),
|
||||
)
|
||||
op.create_table(
|
||||
"user_roles",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("role_id", postgresql.UUID(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["role_id"], ["roles.id"], name=op.f("fk_user_roles_role_id_roles")),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], name=op.f("fk_user_roles_user_id_users")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_user_roles")),
|
||||
sa.UniqueConstraint("user_id", "role_id", name=op.f("uq_user_roles_user_id")),
|
||||
)
|
||||
op.create_table(
|
||||
"products",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("units", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("menu_category_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("sale_category_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("price", sa.Numeric(), nullable=False),
|
||||
sa.Column("has_happy_hour", sa.Boolean(), nullable=False),
|
||||
sa.Column("is_not_available", sa.Boolean(), nullable=False),
|
||||
sa.Column("quantity", sa.Numeric(), nullable=False),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False),
|
||||
sa.Column("sort_order", sa.Numeric(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["menu_category_id"], ["menu_categories.id"], name=op.f("fk_products_menu_category_id_menu_categories")
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["sale_category_id"], ["sale_categories.id"], name=op.f("fk_products_sale_category_id_sale_categories")
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_products")),
|
||||
sa.UniqueConstraint("name", "units", name=op.f("uq_products_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"vouchers",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("date", sa.DateTime(), nullable=False),
|
||||
sa.Column("pax", sa.Numeric(), nullable=False),
|
||||
sa.Column("bill_id", sa.Numeric(), nullable=True),
|
||||
sa.Column("kot_id", sa.Numeric(), nullable=False),
|
||||
sa.Column("creation_date", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("last_edit_date", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("food_table_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("customer_id", postgresql.UUID(), nullable=True),
|
||||
sa.Column("narration", sa.Unicode(length=1000), nullable=False),
|
||||
sa.Column("reason", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("voucher_type", sa.Integer(), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["customer_id"], ["customers.id"], name=op.f("fk_vouchers_customer_id_customers")),
|
||||
sa.ForeignKeyConstraint(
|
||||
["food_table_id"], ["food_tables.id"], name=op.f("fk_vouchers_food_table_id_food_tables")
|
||||
),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], name=op.f("fk_vouchers_user_id_users")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_vouchers")),
|
||||
sa.UniqueConstraint("bill_id", "voucher_type", name=op.f("uq_vouchers_bill_id")),
|
||||
sa.UniqueConstraint("kot_id", name=op.f("uq_vouchers_kot_id")),
|
||||
)
|
||||
op.create_index(op.f("ix_vouchers_date"), "vouchers", ["date"], unique=False)
|
||||
op.create_table(
|
||||
"kots",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("voucher_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("code", sa.Numeric(), nullable=False),
|
||||
sa.Column("food_table_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("date", sa.DateTime(), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["food_table_id"], ["food_tables.id"], name=op.f("fk_kots_food_table_id_food_tables")),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], name=op.f("fk_kots_user_id_users")),
|
||||
sa.ForeignKeyConstraint(["voucher_id"], ["vouchers.id"], name=op.f("fk_kots_voucher_id_vouchers")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_kots")),
|
||||
sa.UniqueConstraint("code", name=op.f("uq_kots_code")),
|
||||
)
|
||||
op.create_index(op.f("ix_kots_date"), "kots", ["date"], unique=False)
|
||||
op.create_index(op.f("ix_kots_voucher_id"), "kots", ["voucher_id"], unique=False)
|
||||
op.create_table(
|
||||
"modifier_categories_products",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("product_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("modifier_categories_id", postgresql.UUID(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["modifier_categories_id"],
|
||||
["modifier_categories.id"],
|
||||
name=op.f("fk_modifier_categories_products_modifier_categories_id_modifier_categories"),
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["product_id"], ["products.id"], name=op.f("fk_modifier_categories_products_product_id_products")
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_modifier_categories_products")),
|
||||
sa.UniqueConstraint(
|
||||
"product_id", "modifier_categories_id", name=op.f("uq_modifier_categories_products_product_id")
|
||||
),
|
||||
)
|
||||
op.create_table(
|
||||
"overview",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("voucher_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("food_table_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("guest_book_id", postgresql.UUID(), nullable=True),
|
||||
sa.Column("status", sa.Unicode(length=255), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["food_table_id"], ["food_tables.id"], name=op.f("fk_overview_food_table_id_food_tables")
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["guest_book_id"], ["guest_book.id"], name=op.f("fk_overview_guest_book_id_guest_book")
|
||||
),
|
||||
sa.ForeignKeyConstraint(["voucher_id"], ["vouchers.id"], name=op.f("fk_overview_voucher_id_vouchers")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_overview")),
|
||||
sa.UniqueConstraint("food_table_id", name=op.f("uq_overview_food_table_id")),
|
||||
sa.UniqueConstraint("guest_book_id", name=op.f("uq_overview_guest_book_id")),
|
||||
sa.UniqueConstraint("voucher_id", name=op.f("uq_overview_voucher_id")),
|
||||
)
|
||||
op.create_table(
|
||||
"reprints",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("date", sa.DateTime(), nullable=False),
|
||||
sa.Column("voucher_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], name=op.f("fk_reprints_user_id_users")),
|
||||
sa.ForeignKeyConstraint(["voucher_id"], ["vouchers.id"], name=op.f("fk_reprints_voucher_id_vouchers")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_reprints")),
|
||||
)
|
||||
op.create_index(op.f("ix_reprints_date"), "reprints", ["date"], unique=False)
|
||||
op.create_index(op.f("ix_reprints_voucher_id"), "reprints", ["voucher_id"], unique=False)
|
||||
op.create_table(
|
||||
"settlements",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("voucher_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("settled", sa.Integer(), nullable=False),
|
||||
sa.Column("amount", sa.Numeric(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["settled"], ["settle_options.id"], name=op.f("fk_settlements_settled_settle_options")),
|
||||
sa.ForeignKeyConstraint(["voucher_id"], ["vouchers.id"], name=op.f("fk_settlements_voucher_id_vouchers")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_settlements")),
|
||||
sa.UniqueConstraint("voucher_id", "settled", name=op.f("uq_settlements_voucher_id")),
|
||||
)
|
||||
op.create_index(op.f("ix_settlements_voucher_id"), "settlements", ["voucher_id"], unique=False)
|
||||
op.create_table(
|
||||
"inventories",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("kot_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("product_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("quantity", sa.Numeric(), nullable=True),
|
||||
sa.Column("price", sa.Numeric(), nullable=True),
|
||||
sa.Column("is_happy_hour", sa.Boolean(), nullable=False),
|
||||
sa.Column("tax_rate", sa.Numeric(), nullable=True),
|
||||
sa.Column("tax_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("discount", sa.Numeric(), nullable=True),
|
||||
sa.Column("sort_order", sa.Numeric(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["kot_id"], ["kots.id"], name=op.f("fk_inventories_kot_id_kots")),
|
||||
sa.ForeignKeyConstraint(["product_id"], ["products.id"], name=op.f("fk_inventories_product_id_products")),
|
||||
sa.ForeignKeyConstraint(["tax_id"], ["taxes.id"], name=op.f("fk_inventories_tax_id_taxes")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_inventories")),
|
||||
sa.UniqueConstraint("kot_id", "product_id", "is_happy_hour", "price", name=op.f("uq_inventories_kot_id")),
|
||||
)
|
||||
op.create_index(op.f("ix_inventories_kot_id"), "inventories", ["kot_id"], unique=False)
|
||||
op.create_table(
|
||||
"inventory_modifiers",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("inventory_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("modifier_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("price", sa.Numeric(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["inventory_id"], ["inventories.id"], name=op.f("fk_inventory_modifiers_inventory_id_inventories")
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["modifier_id"], ["modifiers.id"], name=op.f("fk_inventory_modifiers_modifier_id_modifiers")
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_inventory_modifiers")),
|
||||
sa.UniqueConstraint("inventory_id", "modifier_id", name=op.f("uq_inventory_modifiers_inventory_id")),
|
||||
)
|
||||
|
||||
op.execute(Permission.__table__.insert().values(id="7669dfc9-cc75-4e48-b267-145c8832a83c", name="Guest Book"))
|
||||
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(Section.__table__.insert().values(id="3f13f6e7-dc76-4fca-8fdb-b2bbf29b35df", name="Main"))
|
||||
|
||||
op.execute(
|
||||
ModifierCategory.__table__.insert().values(
|
||||
id="e046ad33-dc65-4c78-8833-c3d3538d44c0",
|
||||
name="Old Modifiers",
|
||||
maximum=None,
|
||||
minimum=0,
|
||||
is_active=True,
|
||||
sort_order=0,
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
ModifierCategory.__table__.insert().values(
|
||||
id="b572f401-3c2f-48b9-8973-ada5a6e4d3a6",
|
||||
name="Bar Instructions",
|
||||
maximum=None,
|
||||
minimum=0,
|
||||
is_active=True,
|
||||
sort_order=0,
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
ModifierCategory.__table__.insert().values(
|
||||
id="caa72832-5034-405e-8442-68a8cc12ace9",
|
||||
name="Delivery",
|
||||
maximum=None,
|
||||
minimum=0,
|
||||
is_active=True,
|
||||
sort_order=0,
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
ModifierCategory.__table__.insert().values(
|
||||
id="d6a0595f-e209-42e4-bb12-b7499f9a9c4d",
|
||||
name="Kitchen Instructions",
|
||||
maximum=None,
|
||||
minimum=0,
|
||||
is_active=True,
|
||||
sort_order=0,
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
ModifierCategory.__table__.insert().values(
|
||||
id="60ca9122-adc5-463b-ad5f-33a68df8c3ae",
|
||||
name="Mixers",
|
||||
maximum=None,
|
||||
minimum=0,
|
||||
is_active=True,
|
||||
sort_order=0,
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
ModifierCategory.__table__.insert().values(
|
||||
id="ef5b1a0b-5eb1-45ff-bd82-3209c8b888df",
|
||||
name="Pasta Sauce",
|
||||
maximum=None,
|
||||
minimum=0,
|
||||
is_active=True,
|
||||
sort_order=0,
|
||||
)
|
||||
)
|
||||
|
||||
op.execute(
|
||||
SettleOption.__table__.insert().values(
|
||||
id=1, name="Unsettled", show_in_choices=False, display_group=1, is_print=True
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
SettleOption.__table__.insert().values(id=2, name="Cash", show_in_choices=True, display_group=2, is_print=False)
|
||||
)
|
||||
op.execute(
|
||||
SettleOption.__table__.insert().values(
|
||||
id=3, name="Credit Card", show_in_choices=True, display_group=2, is_print=True
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
SettleOption.__table__.insert().values(
|
||||
id=4, name="No Charge", show_in_choices=True, display_group=3, is_print=True
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
SettleOption.__table__.insert().values(
|
||||
id=5, name="Bill To Company", show_in_choices=True, display_group=2, is_print=True
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
SettleOption.__table__.insert().values(id=6, name="Tip", show_in_choices=True, display_group=2, is_print=True)
|
||||
)
|
||||
op.execute(
|
||||
SettleOption.__table__.insert().values(
|
||||
id=7, name="Round Off", show_in_choices=False, display_group=1, is_print=False
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
SettleOption.__table__.insert().values(
|
||||
id=8, name="Amount", show_in_choices=False, display_group=1, is_print=False
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
SettleOption.__table__.insert().values(id=9, name="Void", show_in_choices=True, display_group=1, is_print=True)
|
||||
)
|
||||
op.execute(
|
||||
SettleOption.__table__.insert().values(
|
||||
id=10, name="Staff", show_in_choices=True, display_group=4, is_print=True
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
Customer.__table__.insert().values(
|
||||
id="2c716f4b-0736-429a-ad51-610d7c47cb5e", company="", name="Cash", phone="", address=""
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
DbSetting.__table__.insert().values(
|
||||
id="fb738ba2-a3c9-40ed-891c-b930e6454974",
|
||||
name="Header",
|
||||
data={
|
||||
"Text": """ Hops n Grains
|
||||
The Microbrewery
|
||||
SCO 358, Sector 9, Panchkula
|
||||
A Unit of Peitho Foods Pvt. Ltd.
|
||||
CIN: U15139CH2010PTC032202
|
||||
(Reg Add: Plot No. 907, Indl Area II, Chd)
|
||||
TIN: 06592507323
|
||||
Service Tax: AAFCP5097GSD001
|
||||
"""
|
||||
},
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
DbSetting.__table__.insert().values(
|
||||
id="f7799871-d16e-4c4d-9b57-2299a5839acb",
|
||||
name="Footer",
|
||||
data={"Text": "Call: 0172-4026666, 8054923853, 8054923856"},
|
||||
)
|
||||
)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table("inventory_modifiers")
|
||||
op.drop_index(op.f("ix_inventories_kot_id"), table_name="inventories")
|
||||
op.drop_table("inventories")
|
||||
op.drop_index(op.f("ix_settlements_voucher_id"), table_name="settlements")
|
||||
op.drop_table("settlements")
|
||||
op.drop_index(op.f("ix_reprints_voucher_id"), table_name="reprints")
|
||||
op.drop_index(op.f("ix_reprints_date"), table_name="reprints")
|
||||
op.drop_table("reprints")
|
||||
op.drop_table("overview")
|
||||
op.drop_table("modifier_categories_products")
|
||||
op.drop_index(op.f("ix_kots_voucher_id"), table_name="kots")
|
||||
op.drop_index(op.f("ix_kots_date"), table_name="kots")
|
||||
op.drop_table("kots")
|
||||
op.drop_index(op.f("ix_vouchers_date"), table_name="vouchers")
|
||||
op.drop_table("vouchers")
|
||||
op.drop_table("products")
|
||||
op.drop_table("user_roles")
|
||||
op.drop_table("section_printers")
|
||||
op.drop_table("sale_categories")
|
||||
op.drop_table("role_permissions")
|
||||
op.drop_table("modifiers")
|
||||
op.drop_table("guest_book")
|
||||
op.drop_table("food_tables")
|
||||
op.drop_table("devices")
|
||||
op.drop_table("users")
|
||||
op.drop_table("taxes")
|
||||
op.drop_table("settle_options")
|
||||
op.drop_table("settings")
|
||||
op.drop_table("sections")
|
||||
op.drop_table("roles")
|
||||
op.drop_table("printers")
|
||||
op.drop_table("permissions")
|
||||
op.drop_table("modifier_categories")
|
||||
op.drop_table("menu_categories")
|
||||
op.drop_table("customers")
|
||||
op.drop_table("clients")
|
||||
# ### end Alembic commands ###
|
||||
61
barker/pyproject.toml
Normal file
61
barker/pyproject.toml
Normal file
@ -0,0 +1,61 @@
|
||||
[tool.poetry]
|
||||
name = "barker"
|
||||
version = "0.1.0"
|
||||
description = "Point of Sale for a restaurant"
|
||||
authors = ["tanshu <git@tanshu.com>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
uvicorn = "^0.12.1"
|
||||
fastapi = "^0.61.1"
|
||||
python-jose = {extras = ["cryptography"], version = "^3.2.0"}
|
||||
passlib = {extras = ["bcrypt"], version = "^1.7.3"}
|
||||
psycopg2-binary = "^2.8.6"
|
||||
SQLAlchemy = "^1.3.19"
|
||||
python-multipart = "^0.0.5"
|
||||
PyJWT = "^1.7.1"
|
||||
alembic = "^1.4.3"
|
||||
itsdangerous = "^1.1.0"
|
||||
python-dotenv = "^0.14.0"
|
||||
pydantic = {extras = ["dotenv"], version = "^1.6.1"}
|
||||
starlette = "^0.13.6"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
flake8 = "^3.8.4"
|
||||
black = "^20.8b1"
|
||||
isort = "^5.6.2"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.isort]
|
||||
profile = "black"
|
||||
atomic = true
|
||||
include_trailing_comma = true
|
||||
lines_after_imports = 2
|
||||
lines_between_types = 1
|
||||
use_parentheses = true
|
||||
src_paths = ["poetry", "tests"]
|
||||
skip_glob = ["*/setup.py"]
|
||||
filter_files = true
|
||||
known_first_party = "poetry"
|
||||
|
||||
[tool.black]
|
||||
line-length = 88
|
||||
include = '\.pyi?$'
|
||||
exclude = '''
|
||||
/(
|
||||
\.eggs
|
||||
| \.git
|
||||
| \.hg
|
||||
| \.mypy_cache
|
||||
| \.tox
|
||||
| \.venv
|
||||
| _build
|
||||
| buck-out
|
||||
| build
|
||||
| dist
|
||||
| tests/.*/setup.py
|
||||
)/
|
||||
'''
|
||||
Reference in New Issue
Block a user