Database schema change. Removed 'currency' column from 'Product'.
This commit is contained in:
parent
27983883d7
commit
1dddddb97d
10
cli.py
10
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.")
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue
Block a user