From 3ea8e5e2e39cafa49d58703305af0313ed790ff8 Mon Sep 17 00:00:00 2001 From: Sayan Chowdhury Date: Mar 07 2017 15:26:13 +0000 Subject: Add the revision for the initial models Signed-off-by: Sayan Chowdhury --- diff --git a/hubs/migrations/versions/8abb340f5e8a_add_the_intial_models.py b/hubs/migrations/versions/8abb340f5e8a_add_the_intial_models.py new file mode 100644 index 0000000..b5d62a9 --- /dev/null +++ b/hubs/migrations/versions/8abb340f5e8a_add_the_intial_models.py @@ -0,0 +1,113 @@ +# This Alembic database migration is part of the Fedora Hubs project. +# Copyright (C) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +""" +Add the intial models + +Revision ID: 8abb340f5e8a +Revises: 26cc11577009 +Create Date: 2017-03-07 20:30:44.388016 +""" + +from __future__ import absolute_import, unicode_literals + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '8abb340f5e8a' +down_revision = u'26cc11577009' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + 'hubs', + sa.Column('name', sa.String(length=50), nullable=False), + sa.Column('summary', sa.String(length=128), nullable=True), + sa.Column('created_on', sa.DateTime(), nullable=True), + sa.Column('left_width', sa.Integer(), nullable=False), + sa.Column('archived', sa.Boolean(), nullable=True), + sa.Column('user_hub', sa.Boolean(), nullable=True), + sa.Column('avatar', sa.String(length=256), nullable=True), + sa.Column('header_img', sa.String(length=256), nullable=True), + sa.Column('last_refreshed', sa.DateTime(), nullable=True), + sa.Column('last_edited', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('name') + ) + op.create_table( + 'users', + sa.Column('username', sa.Text(), nullable=False), + sa.Column('fullname', sa.Text(), nullable=True), + sa.Column('created_on', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('username') + ) + op.create_table( + 'association', + sa.Column('hub_id', sa.String(length=50), nullable=False), + sa.Column('user_id', sa.Text(), nullable=False), + sa.Column('role', sa.Enum(u'subscriber', u'member', u'owner', u'stargazer'), nullable=False), + sa.ForeignKeyConstraint(['hub_id'], [u'hubs.name'], ), + sa.ForeignKeyConstraint(['user_id'], [u'users.username'], ), + sa.PrimaryKeyConstraint('hub_id', 'user_id', 'role') + ) + op.create_table( + 'savednotifications', + sa.Column('user', sa.Text(), nullable=True), + sa.Column('created', sa.DateTime(), nullable=True), + sa.Column('dom_id', sa.Text(), nullable=True), + sa.Column('idx', sa.Integer(), nullable=False), + sa.Column('link', sa.Text(), nullable=True), + sa.Column('markup', sa.Text(), nullable=True), + sa.Column('secondary_icon', sa.Text(), nullable=True), + sa.ForeignKeyConstraint(['user'], [u'users.username'], ), + sa.PrimaryKeyConstraint('idx') + ) + op.create_table( + 'visit_counter', + sa.Column('count', sa.Integer(), nullable=False), + sa.Column('visited_hub', sa.String(length=50), nullable=False), + sa.Column('username', sa.Text(), nullable=False), + sa.ForeignKeyConstraint(['username'], [u'users.username'], ), + sa.ForeignKeyConstraint(['visited_hub'], [u'hubs.name'], ), + sa.PrimaryKeyConstraint('visited_hub', 'username') + ) + op.create_table( + 'widgets', + sa.Column('idx', sa.Integer(), nullable=False), + sa.Column('plugin', sa.String(length=50), nullable=False), + sa.Column('created_on', sa.DateTime(), nullable=True), + sa.Column('hub_id', sa.String(length=50), nullable=True), + sa.Column('_config', sa.String(length=256), nullable=True), + sa.Column('index', sa.Integer(), nullable=False), + sa.Column('left', sa.Boolean(), nullable=False), + sa.ForeignKeyConstraint(['hub_id'], [u'hubs.name'], ), + sa.PrimaryKeyConstraint('idx') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('widgets') + op.drop_table('visit_counter') + op.drop_table('savednotifications') + op.drop_table('association') + op.drop_table('users') + op.drop_table('hubs') + # ### end Alembic commands ###