From f27cc37c4e20b91dc0165ed56fd6e1120449d4c4 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 11 May 2017 13:51:57 -0500 Subject: [PATCH] Add `Customer.number` field to schema for those who want a proper integer key on the customer table --- .../195ceb6abeb3_add_customer_number.py | 33 +++++++++++++++++++ rattail/db/model/customers.py | 12 ++++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 rattail/db/alembic/versions/195ceb6abeb3_add_customer_number.py diff --git a/rattail/db/alembic/versions/195ceb6abeb3_add_customer_number.py b/rattail/db/alembic/versions/195ceb6abeb3_add_customer_number.py new file mode 100644 index 00000000..fe516981 --- /dev/null +++ b/rattail/db/alembic/versions/195ceb6abeb3_add_customer_number.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +"""add customer number + +Revision ID: 195ceb6abeb3 +Revises: 6a1ec8b93637 +Create Date: 2017-05-11 11:29:13.525277 + +""" + +from __future__ import unicode_literals + +# revision identifiers, used by Alembic. +revision = '195ceb6abeb3' +down_revision = u'6a1ec8b93637' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa +import rattail.db.types +from sqlalchemy.dialects import postgresql + + +def upgrade(): + + # customer + op.add_column('customer', sa.Column('number', sa.Integer(), nullable=True)) + + +def downgrade(): + + # customer + op.drop_column('customer', 'number') diff --git a/rattail/db/model/customers.py b/rattail/db/model/customers.py index fda2f775..5fedab81 100644 --- a/rattail/db/model/customers.py +++ b/rattail/db/model/customers.py @@ -47,7 +47,17 @@ class Customer(Base): __versioned__ = {} uuid = uuid_column() - id = sa.Column(sa.String(length=20)) + + id = sa.Column(sa.String(length=20), nullable=True, doc=""" + String ID for the customer, if known/relevant. This may or may not + correspond to the :attr:`number`, depending on your system. + """) + + number = sa.Column(sa.Integer(), nullable=True, doc=""" + Customer number, if known/relevant. This may or may not correspond to the + :attr:`id`, depending on your system. + """) + name = sa.Column(sa.String(length=255)) email_preference = sa.Column(sa.Integer())