<gh_stars>1-10
"""Added added many to many tables for product tables

Revision ID: 005735b54b04
Revises: <PASSWORD>
Create Date: 2016-08-27 23:24:59.491903

"""

# revision identifiers, used by Alembic.
revision = '005735b54b04'
down_revision = '<PASSWORD>'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.execute("create sequence products_product_attributes_id_seq start with 1 increment by 1")
    op.execute("create sequence products_product_fabrics_id_seq start with 1 increment by 1")
    op.execute("create sequence products_product_manufacturers_id_seq start with 1 increment by 1")
    op.execute("create sequence products_product_photos_id_seq start with 1 increment by 1")
    op.create_table('products_product_attributes',
    sa.Column('id', sa.Integer(), server_default=sa.text("nextval('products_product_attributes_id_seq'::regclass)"), nullable=False),
    sa.Column('product_id', sa.Integer(), nullable=True),
    sa.Column('product_attribute_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['product_attribute_id'], ['product_attribute.id'], onupdate='CASCADE'),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], onupdate='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_products_product_attributes_id', 'products_product_attributes', ['product_id', 'product_attribute_id'], unique=False)
    op.create_table('products_product_fabrics',
    sa.Column('id', sa.Integer(), server_default=sa.text("nextval('products_product_fabrics_id_seq'::regclass)"), nullable=False),
    sa.Column('product_id', sa.Integer(), nullable=True),
    sa.Column('product_fabric_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['product_fabric_id'], ['product_fabric.id'], onupdate='CASCADE'),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], onupdate='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_products_product_fabrics_id', 'products_product_fabrics', ['product_id', 'product_fabric_id'], unique=False)
    op.create_table('products_product_manufacturers',
    sa.Column('id', sa.Integer(), server_default=sa.text("nextval('products_product_manufacturers_id_seq'::regclass)"), nullable=False),
    sa.Column('product_id', sa.Integer(), nullable=True),
    sa.Column('product_manufacturer_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], onupdate='CASCADE'),
    sa.ForeignKeyConstraint(['product_manufacturer_id'], ['product_manufacturer.id'], onupdate='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_products_product_manufacturers_id', 'products_product_manufacturers', ['product_id', 'product_manufacturer_id'], unique=False)
    op.create_table('products_product_photos',
    sa.Column('id', sa.Integer(), server_default=sa.text("nextval('products_product_photos_id_seq'::regclass)"), nullable=False),
    sa.Column('product_id', sa.Integer(), nullable=True),
    sa.Column('product_photo_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], onupdate='CASCADE'),
    sa.ForeignKeyConstraint(['product_photo_id'], ['product_photo.id'], onupdate='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_products_product_photos_id', 'products_product_photos', ['product_id', 'product_photo_id'], unique=False)
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.execute(sa.schema.DropSequence(sa.Sequence("products_product_attributes_id_seq")))
    op.execute(sa.schema.DropSequence(sa.Sequence("products_product_fabrics_id_seq")))
    op.execute(sa.schema.DropSequence(sa.Sequence("products_product_manufacturers_id_seq")))
    op.execute(sa.schema.DropSequence(sa.Sequence("products_product_photos_id_seq")))
    op.drop_index('idx_products_product_photos_id', table_name='products_product_photos')
    op.drop_table('products_product_photos')
    op.drop_index('idx_products_product_manufacturers_id', table_name='products_product_manufacturers')
    op.drop_table('products_product_manufacturers')
    op.drop_index('idx_products_product_fabrics_id', table_name='products_product_fabrics')
    op.drop_table('products_product_fabrics')
    op.drop_index('idx_products_product_attributes_id', table_name='products_product_attributes')
    op.drop_table('products_product_attributes')
    ### end Alembic commands ###

"""Added added many to many tables for product tables

Revision ID: 005735b54b04
Revises: <PASSWORD>
Create Date: 2016-08-27 23:24:59.491903

"""

# revision identifiers, used by Alembic.
revision = '005735b54b04'
down_revision = '<PASSWORD>'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.execute("create sequence products_product_attributes_id_seq start with 1 increment by 1")
    op.execute("create sequence products_product_fabrics_id_seq start with 1 increment by 1")
    op.execute("create sequence products_product_manufacturers_id_seq start with 1 increment by 1")
    op.execute("create sequence products_product_photos_id_seq start with 1 increment by 1")
    op.create_table('products_product_attributes',
    sa.Column('id', sa.Integer(), server_default=sa.text("nextval('products_product_attributes_id_seq'::regclass)"), nullable=False),
    sa.Column('product_id', sa.Integer(), nullable=True),
    sa.Column('product_attribute_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['product_attribute_id'], ['product_attribute.id'], onupdate='CASCADE'),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], onupdate='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_products_product_attributes_id', 'products_product_attributes', ['product_id', 'product_attribute_id'], unique=False)
    op.create_table('products_product_fabrics',
    sa.Column('id', sa.Integer(), server_default=sa.text("nextval('products_product_fabrics_id_seq'::regclass)"), nullable=False),
    sa.Column('product_id', sa.Integer(), nullable=True),
    sa.Column('product_fabric_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['product_fabric_id'], ['product_fabric.id'], onupdate='CASCADE'),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], onupdate='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_products_product_fabrics_id', 'products_product_fabrics', ['product_id', 'product_fabric_id'], unique=False)
    op.create_table('products_product_manufacturers',
    sa.Column('id', sa.Integer(), server_default=sa.text("nextval('products_product_manufacturers_id_seq'::regclass)"), nullable=False),
    sa.Column('product_id', sa.Integer(), nullable=True),
    sa.Column('product_manufacturer_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], onupdate='CASCADE'),
    sa.ForeignKeyConstraint(['product_manufacturer_id'], ['product_manufacturer.id'], onupdate='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_products_product_manufacturers_id', 'products_product_manufacturers', ['product_id', 'product_manufacturer_id'], unique=False)
    op.create_table('products_product_photos',
    sa.Column('id', sa.Integer(), server_default=sa.text("nextval('products_product_photos_id_seq'::regclass)"), nullable=False),
    sa.Column('product_id', sa.Integer(), nullable=True),
    sa.Column('product_photo_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], onupdate='CASCADE'),
    sa.ForeignKeyConstraint(['product_photo_id'], ['product_photo.id'], onupdate='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_products_product_photos_id', 'products_product_photos', ['product_id', 'product_photo_id'], unique=False)
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.execute(sa.schema.DropSequence(sa.Sequence("products_product_attributes_id_seq")))
    op.execute(sa.schema.DropSequence(sa.Sequence("products_product_fabrics_id_seq")))
    op.execute(sa.schema.DropSequence(sa.Sequence("products_product_manufacturers_id_seq")))
    op.execute(sa.schema.DropSequence(sa.Sequence("products_product_photos_id_seq")))
    op.drop_index('idx_products_product_photos_id', table_name='products_product_photos')
    op.drop_table('products_product_photos')
    op.drop_index('idx_products_product_manufacturers_id', table_name='products_product_manufacturers')
    op.drop_table('products_product_manufacturers')
    op.drop_index('idx_products_product_fabrics_id', table_name='products_product_fabrics')
    op.drop_table('products_product_fabrics')
    op.drop_index('idx_products_product_attributes_id', table_name='products_product_attributes')
    op.drop_table('products_product_attributes')
    ### end Alembic commands ###
Added added many to many tables for product tables  Revision ID: 005735b54b04 Revises: <PASSWORD> Create Date: 2016-08-27 23:24:59.491903 # revision identifiers, used by Alembic. ### commands auto generated by Alembic - please adjust! ### ### end Alembic commands ### ### commands auto generated by Alembic - please adjust! ### ### end Alembic commands ###