-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpersistent.py
108 lines (88 loc) · 6 KB
/
persistent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# coding: utf-8
from sqlalchemy import Column, Date, DateTime, ForeignKey, Index, String, TIMESTAMP, Text, text
from sqlalchemy.dialects.mysql import INTEGER, SMALLINT
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
metadata = Base.metadata
class StoreWebsite(Base):
__tablename__ = 'store_website'
__table_args__ = {'comment': 'Websites'}
website_id = Column(SMALLINT(5), primary_key=True, comment='Website ID')
code = Column(String(32), unique=True, comment='Code')
name = Column(String(64), comment='Website Name')
sort_order = Column(SMALLINT(5), nullable=False, index=True, server_default=text("0"), comment='Sort Order')
default_group_id = Column(SMALLINT(5), nullable=False, index=True, server_default=text("0"), comment='Default Group ID')
is_default = Column(SMALLINT(5), server_default=text("0"), comment='Defines Is Website Default')
class StoreGroup(Base):
__tablename__ = 'store_group'
__table_args__ = {'comment': 'Store Groups'}
group_id = Column(SMALLINT(5), primary_key=True, comment='Group ID')
website_id = Column(ForeignKey('store_website.website_id', ondelete='CASCADE'), nullable=False, index=True, server_default=text("0"), comment='Website ID')
name = Column(String(255), nullable=False, comment='Store Group Name')
root_category_id = Column(INTEGER(10), nullable=False, server_default=text("0"), comment='Root Category ID')
default_store_id = Column(SMALLINT(5), nullable=False, index=True, server_default=text("0"), comment='Default Store ID')
code = Column(String(32), unique=True, comment='Store group unique code')
website = relationship('StoreWebsite')
class Store(Base):
__tablename__ = 'store'
__table_args__ = (
Index('STORE_IS_ACTIVE_SORT_ORDER', 'is_active', 'sort_order'),
{'comment': 'Stores'}
)
store_id = Column(SMALLINT(5), primary_key=True, comment='Store ID')
code = Column(String(32), unique=True, comment='Code')
website_id = Column(ForeignKey('store_website.website_id', ondelete='CASCADE'), nullable=False, index=True, server_default=text("0"), comment='Website ID')
group_id = Column(ForeignKey('store_group.group_id', ondelete='CASCADE'), nullable=False, index=True, server_default=text("0"), comment='Group ID')
name = Column(String(255), nullable=False, comment='Store Name')
sort_order = Column(SMALLINT(5), nullable=False, server_default=text("0"), comment='Store Sort Order')
is_active = Column(SMALLINT(5), nullable=False, server_default=text("0"), comment='Store Activity')
group = relationship('StoreGroup')
website = relationship('StoreWebsite')
class CustomerEntity(Base):
__tablename__ = 'customer_entity'
__table_args__ = (
Index('CUSTOMER_ENTITY_EMAIL_WEBSITE_ID', 'email', 'website_id', unique=True),
{'comment': 'Customer Entity'}
)
entity_id = Column(INTEGER(10), primary_key=True, comment='Entity ID')
website_id = Column(ForeignKey('store_website.website_id', ondelete='SET NULL'), index=True, comment='Website ID')
email = Column(String(255), comment='Email')
group_id = Column(SMALLINT(5), nullable=False, server_default=text("0"), comment='Group ID')
increment_id = Column(String(50), comment='Increment ID')
store_id = Column(ForeignKey('store.store_id', ondelete='SET NULL'), index=True, server_default=text("0"), comment='Store ID')
created_at = Column(TIMESTAMP, nullable=False, server_default=text("current_timestamp()"), comment='Created At')
updated_at = Column(TIMESTAMP, nullable=False, server_default=text("current_timestamp() ON UPDATE current_timestamp()"), comment='Updated At')
is_active = Column(SMALLINT(5), nullable=False, server_default=text("1"), comment='Is Active')
disable_auto_group_change = Column(SMALLINT(5), nullable=False, server_default=text("0"), comment='Disable automatic group change based on VAT ID')
created_in = Column(String(255), comment='Created From')
prefix = Column(String(40), comment='Name Prefix')
firstname = Column(String(255), index=True, comment='First Name')
middlename = Column(String(255), comment='Middle Name/Initial')
lastname = Column(String(255), index=True, comment='Last Name')
suffix = Column(String(40), comment='Name Suffix')
dob = Column(Date, comment='Date of Birth')
password_hash = Column(String(128), comment='Password_hash')
rp_token = Column(String(128), comment='Reset password token')
rp_token_created_at = Column(DateTime, comment='Reset password token creation time')
default_billing = Column(INTEGER(10), comment='Default Billing Address')
default_shipping = Column(INTEGER(10), comment='Default Shipping Address')
taxvat = Column(String(50), comment='Tax/VAT Number')
confirmation = Column(String(64), comment='Is Confirmed')
gender = Column(SMALLINT(5), comment='Gender')
failures_num = Column(SMALLINT(6), server_default=text("0"), comment='Failure Number')
first_failure = Column(TIMESTAMP, comment='First Failure')
lock_expires = Column(TIMESTAMP, comment='Lock Expiration Date')
store = relationship('Store')
website = relationship('StoreWebsite')
class PersistentSession(Base):
__tablename__ = 'persistent_session'
__table_args__ = {'comment': 'Persistent Session'}
persistent_id = Column(INTEGER(10), primary_key=True, comment='Session ID')
key = Column(String(50), nullable=False, unique=True, comment='Unique cookie key')
customer_id = Column(ForeignKey('customer_entity.entity_id', ondelete='CASCADE'), unique=True, comment='Customer ID')
website_id = Column(ForeignKey('store_website.website_id', ondelete='CASCADE'), nullable=False, index=True, server_default=text("0"), comment='Website ID')
info = Column(Text, comment='Session Data')
updated_at = Column(TIMESTAMP, nullable=False, index=True, server_default=text("current_timestamp() ON UPDATE current_timestamp()"), comment='Updated At')
customer = relationship('CustomerEntity')
website = relationship('StoreWebsite')