From 1dddddb97d15f9a6ad8a571585037e880dd1bdb5 Mon Sep 17 00:00:00 2001 From: crudo Date: Wed, 22 Mar 2017 17:56:54 +0100 Subject: [PATCH] Database schema change. Removed 'currency' column from 'Product'. --- cli.py | 10 ++++------ pos/database.py | 3 --- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cli.py b/cli.py index a702046..c08dd7a 100644 --- a/cli.py +++ b/cli.py @@ -99,19 +99,17 @@ def product(): def tabulate_products(products): - tab = [["UID", "Name", "Price", "Currency", "Enabled", "Created at"]] + tab = [["UID", "Name", "Price", "Enabled", "Created at"]] for p in products: - tab.append([p.uid, p.name, p.price, p.currency, - p.is_active, p.created_at]) + tab.append([p.uid, p.name, p.price, p.is_active, p.created_at]) return tabulate(tab, headers='firstrow') @product.command('add') @click.argument('name') @click.argument('price') -@click.option('--currency') -def product_add(name, price, currency): - product = Product(name=name, currency=currency, price=price) +def product_add(name, price): + product = Product(name=name, price=price) with db.get_session() as session: session.add(product) print("Product succesfully added.") diff --git a/pos/database.py b/pos/database.py index 9bad621..cd5576a 100644 --- a/pos/database.py +++ b/pos/database.py @@ -10,7 +10,6 @@ from sqlalchemy.orm import relationship from sqlalchemy_utils import force_auto_coercion from sqlalchemy_utils.types.password import PasswordType -from sqlalchemy_utils.types.currency import CurrencyType from pos.logging import get_logger @@ -23,7 +22,6 @@ ENGINE_SQLITE = "sqlite:///{path}" ENGINE_SQLITE_MEMORY = "sqlite://" PASSWORD_SCHEMES = ['pbkdf2_sha512'] -DEFAULT_CURRENCY = 'EUR' Base = sqlalchemy.ext.declarative.declarative_base() @@ -119,7 +117,6 @@ class Product(Base): __tablename__ = 'products' uid = Column(Integer, primary_key=True) name = Column(String, nullable=False) - currency = Column(CurrencyType, nullable=False, default=DEFAULT_CURRENCY) price = Column(Integer, nullable=False) created_at = Column(DateTime, nullable=False, default=datetime.now) is_active = Column(Boolean, nullable=False, server_default='1')