Fixed migrations and dev requirements

master
androiddrew 7 years ago
parent e67b099e89
commit 3ef86bca1e

@ -2,6 +2,7 @@ import bcrypt
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Boolean, Numeric
from sqlalchemy.orm import relationship, backref
from sqlalchemy.schema import CreateColumn
from sqlalchemy.sql import expression
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.types import DateTime as DateTimeType
@ -20,6 +21,13 @@ def pg_utcnow(element, compiler, **kw):
return "TIMEZONE('utc', CURRENT_TIMESTAMP)"
@compiles(CreateColumn, 'postgresql')
def use_identity(element, compiler, **kw):
text = compiler.visit_create_column(element, **kw)
text = text.replace("SERIAL", "INT GENERATED BY DEFAULT AS IDENTITY")
return text
Base = declarative_base()

@ -0,0 +1,4 @@
alembic
pytest
pytest-cov
tox

@ -4,17 +4,20 @@
#
# pip-compile --output-file dev_requirements.txt dev_requirements.in
#
alembic==0.9.9
atomicwrites==1.1.5 # via pytest
attrs==18.1.0 # via pytest
click==6.7 # via pip-tools
coverage==4.5.1 # via pytest-cov
first==2.0.1 # via pip-tools
mako==1.0.7 # via alembic
markupsafe==1.0 # via mako
more-itertools==4.2.0 # via pytest
pip-tools==2.0.2
pluggy==0.6.0 # via pytest, tox
py==1.5.3 # via pytest, tox
pytest-cov==2.5.1
pytest==3.6.1
six==1.11.0 # via more-itertools, pip-tools, pytest, tox
python-dateutil==2.7.3 # via alembic
python-editor==1.0.3 # via alembic
six==1.11.0 # via more-itertools, pytest, python-dateutil, tox
sqlalchemy==1.2.8 # via alembic
tox==3.0.0
virtualenv==16.0.0 # via tox

@ -18,7 +18,6 @@ fileConfig(config.config_file_name)
# target_metadata = mymodel.Base.metadata
target_metadata = Base.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")
@ -66,7 +65,6 @@ def run_migrations_online():
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:

@ -1,28 +0,0 @@
"""initial models
Revision ID: 227892845cde
Revises:
Create Date: 2018-01-15 14:58:17.931063
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '227892845cde'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###

@ -0,0 +1,75 @@
"""Cookie Domain Model
Revision ID: 374c36260db7
Revises: 710505cf5d4c
Create Date: 2018-06-10 17:39:18.891568
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '374c36260db7'
down_revision = '710505cf5d4c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('cookies',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_date', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"), nullable=True),
sa.Column('modified_date', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"), nullable=True),
sa.Column('name', sa.String(length=50), nullable=True),
sa.Column('recipe_url', sa.String(length=255), nullable=True),
sa.Column('sku', sa.String(length=55), nullable=True),
sa.Column('qoh', sa.Integer(), nullable=True),
sa.Column('unit_cost', sa.Numeric(precision=12, scale=2), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_cookies_name'), 'cookies', ['name'], unique=False)
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_date', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"), nullable=True),
sa.Column('modified_date', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"), nullable=True),
sa.Column('email', sa.String(length=255), nullable=False),
sa.Column('password', sa.String(length=255), nullable=True),
sa.Column('admin', sa.Boolean(), nullable=False),
sa.Column('confirmed', sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email')
)
op.create_table('orders',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_date', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"), nullable=True),
sa.Column('modified_date', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('shipped', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('line_items',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_date', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"), nullable=True),
sa.Column('modified_date', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"), nullable=True),
sa.Column('order_id', sa.Integer(), nullable=False),
sa.Column('cookie_id', sa.Integer(), nullable=False),
sa.Column('quantity', sa.Integer(), nullable=True),
sa.Column('extended_cost', sa.Numeric(precision=12, scale=2), nullable=True),
sa.ForeignKeyConstraint(['cookie_id'], ['cookies.id'], ),
sa.ForeignKeyConstraint(['order_id'], ['orders.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('line_items')
op.drop_table('orders')
op.drop_table('users')
op.drop_index(op.f('ix_cookies_name'), table_name='cookies')
op.drop_table('cookies')
# ### end Alembic commands ###

@ -0,0 +1,24 @@
"""Empty Init
Revision ID: 710505cf5d4c
Revises:
Create Date: 2018-06-10 17:31:37.014032
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '710505cf5d4c'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass

@ -1,67 +0,0 @@
"""Changed Datetimes to be UTC
Revision ID: 7eb9aabef1dc
Revises: 82595a1e5193
Create Date: 2018-05-07 13:59:32.923484
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '7eb9aabef1dc'
down_revision = '82595a1e5193'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
table_name='cookies',
column_name='created_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='cookies',
column_name='modified_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='users',
column_name='created_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='users',
column_name='modified_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='orders',
column_name='created_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='orders',
column_name='modified_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='line_items',
column_name='created_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='line_items',
column_name='modified_date',
type_=sa.DateTime(timezone=True)
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###

@ -1,30 +0,0 @@
"""Added confirmed to user
Revision ID: 82595a1e5193
Revises: 227892845cde
Create Date: 2018-01-15 15:34:46.028181
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '82595a1e5193'
down_revision = '227892845cde'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('users', sa.Column('confirmed', sa.Boolean()))
op.execute('UPDATE users SET confirmed=FALSE')
op.alter_column('users', 'confirmed', nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('users', 'confirmed')
# ### end Alembic commands ###

@ -23,7 +23,7 @@ pyjwt==1.6.4 # via apistar-jwt
pyyaml==3.12 # via apistar
requests==2.18.4 # via apistar
six==1.11.0 # via bcrypt
sqlalchemy==1.2.7
sqlalchemy==1.2.8
urllib3==1.22 # via requests
werkzeug==0.14.1 # via apistar
whitenoise==3.3.1 # via apistar

@ -11,7 +11,7 @@ requirements = [
'itsdangerous==0.24',
'logbook==1.3.3',
'psycopg2-binary==2.7.4',
'sqlalchemy==1.2.7',
'sqlalchemy==1.2.8',
]
test_requirements = [

Loading…
Cancel
Save