diff --git a/storyboard/db/migration/README b/storyboard/db/migration/README index ecb7f611..0fa969ff 100644 --- a/storyboard/db/migration/README +++ b/storyboard/db/migration/README @@ -20,6 +20,10 @@ can run sequentially to update the database. The scripts are executed by storyboard's migration wrapper which uses the Alembic library to manage the migration. +If your existing database version is currently < 049, you are advised to +run the upgrade command using commit `acce431b30a32497064ad6d1ab3872358e1e60dc` +of this repository, since after that the migrations were consolidated and +will no longer work with existing databases older than version 049. You can upgrade to the latest database version via: $ storyboard-db-manage --config-file /path/to/storyboard.conf upgrade head diff --git a/storyboard/db/migration/alembic_migrations/versions/001_initial_version.py b/storyboard/db/migration/alembic_migrations/versions/001_initial_version.py index 32616f5d..81992cb8 100644 --- a/storyboard/db/migration/alembic_migrations/versions/001_initial_version.py +++ b/storyboard/db/migration/alembic_migrations/versions/001_initial_version.py @@ -25,28 +25,37 @@ down_revision = None from alembic import op +from oslo_log import log import sqlalchemy as sa +from sqlalchemy.sql.expression import table + +from storyboard.db.models import MYSQL_MEDIUM_TEXT + +LOG = log.getLogger(__name__) MYSQL_ENGINE = 'InnoDB' MYSQL_CHARSET = 'utf8' def _define_enums(): - branch_status = sa.Enum( - 'master', 'release', 'stable', 'unsupported', - name='branch_status') + pref_type = sa.Enum('string', 'int', 'bool', 'float') - storyboard_priority = sa.Enum( - 'Undefined', 'Low', 'Medium', 'High', 'Critical', - name='priority') + task_priority = sa.Enum( + 'low', 'medium', 'high', + name='task_priority') task_status = sa.Enum( - 'Todo', 'In review', 'Landed', + 'todo', 'inprogress', 'invalid', 'review', 'merged', name='task_status') + target_type = sa.Enum( + 'task', 'story', 'project', 'project_group', + name='target_type') + return { - 'branch_status': branch_status, - 'storyboard_priority': storyboard_priority, + 'pref_type': pref_type, + 'target_type': target_type, + 'task_priority': task_priority, 'task_status': task_status } @@ -54,48 +63,45 @@ def _define_enums(): def upgrade(active_plugins=None, options=None): enums = _define_enums() - op.create_table( - 'branches', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('name', sa.String(length=50), nullable=True), - sa.Column('status', enums['branch_status'], nullable=True), - sa.Column('release_date', sa.DateTime(), nullable=True), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('name', name='uniq_branch_name'), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) op.create_table( 'project_groups', sa.Column('id', sa.Integer(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('name', sa.String(length=50), nullable=True), - sa.Column('title', sa.Unicode(length=100), nullable=True), + sa.Column('title', sa.Unicode(length=255), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name', name='uniq_group_name'), mysql_engine=MYSQL_ENGINE, mysql_charset=MYSQL_CHARSET ) + op.create_table( + 'user_preferences', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.Column('user_id', sa.Integer(), nullable=False), + sa.Column('key', sa.Unicode(100), nullable=False), + sa.Column('type', enums['pref_type'], nullable=False), + sa.Column('value', sa.Unicode(255), nullable=False), + sa.PrimaryKeyConstraint('id') + ) op.create_table( 'users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('username', sa.Unicode(length=30), nullable=True), - sa.Column('first_name', sa.Unicode(length=30), nullable=True), - sa.Column('last_name', sa.Unicode(length=30), nullable=True), + sa.Column('full_name', sa.Unicode(255), nullable=True), sa.Column('email', sa.String(length=255), nullable=True), - sa.Column('password', sa.UnicodeText(), nullable=True), + sa.Column('openid', sa.String(255)), sa.Column('is_staff', sa.Boolean(), nullable=True), sa.Column('is_active', sa.Boolean(), nullable=True), sa.Column('is_superuser', sa.Boolean(), nullable=True), sa.Column('last_login', sa.DateTime(), nullable=True), + sa.Column('enable_login', sa.Boolean(), default=True, + server_default="1", nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email', name='uniq_user_email'), - sa.UniqueConstraint('username', name='uniq_user_username'), mysql_engine=MYSQL_ENGINE, mysql_charset=MYSQL_CHARSET ) @@ -158,38 +164,27 @@ def upgrade(active_plugins=None, options=None): sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('creator_id', sa.Integer(), nullable=True), - sa.Column('title', sa.Unicode(length=100), nullable=True), + sa.Column('title', sa.Unicode(length=255), nullable=True), sa.Column('description', sa.UnicodeText(), nullable=True), sa.Column('is_bug', sa.Boolean(), nullable=True), - sa.Column('priority', enums['storyboard_priority'], nullable=True), + sa.Column('story_type_id', sa.Integer(), default=1), sa.ForeignKeyConstraint(['creator_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id'), mysql_engine=MYSQL_ENGINE, mysql_charset=MYSQL_CHARSET ) - op.create_table( - 'milestones', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('name', sa.String(length=50), nullable=True), - sa.Column('branch_id', sa.Integer(), nullable=True), - sa.Column('released', sa.Boolean(), nullable=True), - sa.Column('undefined', sa.Boolean(), nullable=True), - sa.ForeignKeyConstraint(['branch_id'], ['branches.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('name', name='uniq_milestone_name'), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) op.create_table( 'projects', sa.Column('id', sa.Integer(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('name', sa.String(length=50), nullable=True), - sa.Column('description', sa.Unicode(length=100), nullable=True), + sa.Column('description', sa.UnicodeText(), nullable=True), sa.Column('team_id', sa.Integer(), nullable=True), + sa.Column('is_active', sa.Boolean(), default=True, + server_default='1', nullable=False), + sa.Column('repo_url', sa.String(255), default=None, nullable=True), + sa.Column('autocreate_branches', sa.Boolean(), default=False), sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name', name='uniq_project_name'), @@ -211,16 +206,17 @@ def upgrade(active_plugins=None, options=None): sa.Column('id', sa.Integer(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('title', sa.Unicode(length=100), nullable=True), + sa.Column('title', sa.Unicode(length=255), nullable=True), sa.Column('status', enums['task_status'], nullable=True), sa.Column('story_id', sa.Integer(), nullable=True), sa.Column('project_id', sa.Integer(), nullable=True), sa.Column('assignee_id', sa.Integer(), nullable=True), + sa.Column('creator_id', sa.Integer(), nullable=True), + sa.Column('priority', enums['task_priority'], nullable=True), + sa.Column('branch_id', sa.Integer(), nullable=True), sa.Column('milestone_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['assignee_id'], ['users.id'], name='tasks_ibfk_1'), - sa.ForeignKeyConstraint(['milestone_id'], ['milestones.id'], - name='tasks_ibfk_2'), sa.ForeignKeyConstraint(['project_id'], ['projects.id'], name='tasks_ibfk_3'), sa.ForeignKeyConstraint(['story_id'], ['stories.id'], @@ -229,18 +225,28 @@ def upgrade(active_plugins=None, options=None): mysql_engine=MYSQL_ENGINE, mysql_charset=MYSQL_CHARSET ) + op.create_table( + 'events', + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('story_id', sa.Integer(), nullable=True), + sa.Column('comment_id', sa.Integer(), nullable=True), + sa.Column('author_id', sa.Integer(), nullable=True), + sa.Column('event_type', sa.Unicode(length=100), nullable=False), + sa.Column('event_info', sa.UnicodeText(), nullable=True), + sa.PrimaryKeyConstraint('id'), + mysql_engine=MYSQL_ENGINE, + mysql_charset=MYSQL_CHARSET + ) op.create_table( 'comments', sa.Column('id', sa.Integer(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('action', sa.String(length=150), nullable=True), - sa.Column('comment_type', sa.String(length=20), nullable=True), - sa.Column('content', sa.UnicodeText(), nullable=True), - sa.Column('story_id', sa.Integer(), nullable=True), - sa.Column('author_id', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['story_id'], ['stories.id'], ), + sa.Column('content', type_=MYSQL_MEDIUM_TEXT, nullable=True), + sa.Column('is_active', sa.Boolean(), default=True, + server_default='1', nullable=False), sa.PrimaryKeyConstraint('id'), mysql_engine=MYSQL_ENGINE, mysql_charset=MYSQL_CHARSET @@ -250,14 +256,232 @@ def upgrade(active_plugins=None, options=None): sa.Column('id', sa.Integer(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('name', sa.String(length=20), nullable=True), - sa.Column('story_id', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['story_id'], ['stories.id'], ), + sa.Column('name', sa.String(length=50), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name', name='uniq_story_tags_name'), mysql_engine=MYSQL_ENGINE, mysql_charset=MYSQL_CHARSET ) + op.create_table('story_storytags', + sa.Column('story_id', sa.Integer(), nullable=True), + sa.Column('storytag_id', sa.Integer(), nullable=True), + mysql_engine=MYSQL_ENGINE, + mysql_charset=MYSQL_CHARSET + ) + op.create_table( + 'subscriptions', + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('user_id', sa.Integer(), nullable=True), + sa.Column('target_type', enums['target_type'], nullable=True), + sa.Column('target_id', sa.Integer(), nullable=True), + sa.PrimaryKeyConstraint('id'), + mysql_engine=MYSQL_ENGINE, + mysql_charset=MYSQL_CHARSET + ) + op.create_table( + 'subscription_events', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.Column('subscriber_id', sa.Integer(), nullable=False), + sa.Column('event_type', sa.Unicode(100), nullable=False), + sa.Column('event_info', sa.UnicodeText(), nullable=True), + sa.Column('author_id', sa.Integer()), + sa.PrimaryKeyConstraint('id'), + mysql_engine=MYSQL_ENGINE, + mysql_charset=MYSQL_CHARSET + ) + op.create_table( + 'authorizationcodes', + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('code', sa.Unicode(100), nullable=False), + sa.Column('state', sa.Unicode(100), nullable=False), + sa.Column('user_id', sa.Integer(), nullable=False), + sa.Column('expires_in', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id'), + mysql_engine=MYSQL_ENGINE, + mysql_charset=MYSQL_CHARSET + ) + op.create_table( + 'accesstokens', + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('user_id', sa.Integer(), nullable=False), + sa.Column('access_token', sa.Unicode(length=100), nullable=False), + sa.Column('expires_in', sa.Integer(), nullable=False), + sa.Column('expires_at', sa.DateTime(), nullable=False), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id'), + mysql_default_charset=MYSQL_CHARSET, + mysql_engine=MYSQL_ENGINE + ) + op.create_table( + 'refreshtokens', + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('user_id', sa.Integer(), nullable=False), + sa.Column('refresh_token', sa.Unicode(length=100), nullable=False), + sa.Column('expires_at', sa.DateTime(), nullable=False), + sa.Column('expires_in', sa.Integer(), nullable=False), + sa.Column('access_token_id', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id'), + mysql_default_charset=MYSQL_CHARSET, + mysql_engine=MYSQL_ENGINE + ) + op.create_table( + 'branches', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(100), nullable=True), + sa.Column('project_id', sa.Integer(), nullable=True), + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.Column('expired', sa.Boolean(), default=False, nullable=True), + sa.Column('expiration_date', sa.DateTime(), default=None, + nullable=True), + sa.Column('autocreated', sa.Boolean(), default=False, nullable=True), + sa.Column('restricted', sa.Boolean(), default=False), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('name', 'project_id', name="branch_un_constr"), + mysql_engine=MYSQL_ENGINE, + mysql_charset=MYSQL_CHARSET + ) + op.create_table( + 'milestones', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(100), nullable=True), + sa.Column('branch_id', sa.Integer(), nullable=True), + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.Column('expired', sa.Boolean(), default=False, nullable=True), + sa.Column('expiration_date', sa.DateTime(), default=None), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('name', 'branch_id', name="milestone_un_constr"), + mysql_engine=MYSQL_ENGINE, + mysql_charset=MYSQL_CHARSET + ) + op.create_table( + 'story_types', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.Column('name', sa.String(50), nullable=True), + sa.Column('icon', sa.String(50), nullable=True), + sa.Column('restricted', sa.Boolean(), default=False), + sa.Column('private', sa.Boolean(), default=False), + sa.Column('visible', sa.Boolean(), default=True), + sa.PrimaryKeyConstraint('id'), + mysql_engine=MYSQL_ENGINE, + mysql_charset=MYSQL_CHARSET + ) + op.create_table( + 'may_mutate_to', + sa.Column('story_type_id_from', sa.Integer(), nullable=False), + sa.Column('story_type_id_to', sa.Integer(), nullable=False), + sa.UniqueConstraint('story_type_id_from', + 'story_type_id_to', + name="mutate_un_constr"), + sa.PrimaryKeyConstraint(), + mysql_engine=MYSQL_ENGINE, + mysql_charset=MYSQL_CHARSET + ) + + # Create story types + bind = op.get_bind() + story_types_table = table( + 'story_types', + sa.Column('name', sa.String(50), nullable=True), + sa.Column('icon', sa.String(50), nullable=True), + sa.Column('restricted', sa.Boolean(), default=False), + sa.Column('private', sa.Boolean(), default=False), + sa.Column('visible', sa.Boolean(), default=True), + ) + bind.execute(story_types_table.insert().values( + name='bug', + icon='fa-bug' + )) + bind.execute(story_types_table.insert().values( + name='feature', + icon='fa-lightbulb-o', + restricted=True + )) + bind.execute(story_types_table.insert().values( + name='private_vulnerability', + icon='fa-lock', + private=True + )) + bind.execute(story_types_table.insert().values( + name='public_vulnerability', + icon='fa-bomb', + visible=False + )) + + # Populate may_mutate_to + may_mutate_to = table( + 'may_mutate_to', + sa.Column('story_type_id_from', sa.Integer(), nullable=False), + sa.Column('story_type_id_to', sa.Integer(), nullable=False), + ) + bind.execute(may_mutate_to.insert().values( + story_type_id_from=1, + story_type_id_to=4 + )) + bind.execute(may_mutate_to.insert().values( + story_type_id_from=1, + story_type_id_to=2 + )) + bind.execute(may_mutate_to.insert().values( + story_type_id_from=2, + story_type_id_to=1 + )) + bind.execute(may_mutate_to.insert().values( + story_type_id_from=3, + story_type_id_to=4 + )) + bind.execute(may_mutate_to.insert().values( + story_type_id_from=3, + story_type_id_to=1 + )) + bind.execute(may_mutate_to.insert().values( + story_type_id_from=4, + story_type_id_to=1 + )) + + op.create_index('accesstokens_access_token_idx', + 'accesstokens', ['access_token']) + + version_info = op.get_bind().engine.dialect.server_version_info + if version_info[-1] == "MariaDB": + # Removes fake mysql prefix + version_info = version_info[-4:] + if version_info[0] < 5 or version_info[0] == 5 and version_info[1] < 6: + LOG.warning( + "MySQL version is lower than 5.6. Skipping full-text indexes") + return + + # Index for projects + op.execute("ALTER TABLE projects " + "ADD FULLTEXT projects_fti (name, description)") + + # Index for stories + op.execute("ALTER TABLE stories " + "ADD FULLTEXT stories_fti (title, description)") + + # Index for tasks + op.execute("ALTER TABLE tasks ADD FULLTEXT tasks_fti (title)") + + # Index for comments + op.execute("ALTER TABLE comments ADD FULLTEXT comments_fti (content)") + + # Index for users + op.execute("ALTER TABLE users ADD FULLTEXT users_fti (full_name, email)") def downgrade(active_plugins=None, options=None): @@ -267,6 +491,7 @@ def downgrade(active_plugins=None, options=None): op.drop_table('team_permissions') op.drop_table('user_permissions') op.drop_table('storytags') + op.drop_table('story_storytags') op.drop_table('comments') op.drop_table('tasks') op.drop_table('projects') @@ -277,6 +502,16 @@ def downgrade(active_plugins=None, options=None): op.drop_table('users') op.drop_table('project_groups') op.drop_table('branches') + op.drop_table('authorizationcodes') + op.drop_table('refreshtokens') + op.drop_table('accesstokens') + op.drop_table('subscriptions') + op.drop_table('subscription_events') + op.drop_table('user_preferences') + op.drop_table('branches') + op.drop_table('milestones') + op.drop_table('story_types') + op.drop_table('may_mutate_to') # Need to explicitly delete enums during migrations for Postgres enums = _define_enums() diff --git a/storyboard/db/migration/alembic_migrations/versions/002_user_update.py b/storyboard/db/migration/alembic_migrations/versions/002_user_update.py deleted file mode 100644 index 1a71f13a..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/002_user_update.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""user update - -Revision ID: 002 -Revises: 001 -Create Date: 2014-02-21 13:21:59.917098 - -""" - -# revision identifiers, used by Alembic. -revision = '002' -down_revision = '001' - - -from alembic import op -import sqlalchemy as sa - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - - op.drop_column('users', 'password') - op.add_column('users', sa.Column('openid', sa.String(255))) - - -def downgrade(active_plugins=None, options=None): - - op.add_column('users', sa.Column('password', sa.UnicodeText)) - op.drop_column('users', 'openid') diff --git a/storyboard/db/migration/alembic_migrations/versions/003_deletion_states.py b/storyboard/db/migration/alembic_migrations/versions/003_deletion_states.py deleted file mode 100644 index 27f50c6e..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/003_deletion_states.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""deletion states - -Revision ID: 003 -Revises: 002 -Create Date: 2014-03-03 16:08:12.584302 - -""" - -# revision identifiers, used by Alembic. -revision = '003' -down_revision = '002' - -from alembic import op -from sqlalchemy import Boolean -from sqlalchemy import Column - - -def upgrade(active_plugins=None, options=None): - op.add_column('projects', - Column('is_active', Boolean(), default=True)) - op.add_column('stories', - Column('is_active', Boolean(), default=True)) - op.add_column('tasks', - Column('is_active', Boolean(), default=True)) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('projects', 'is_active') - op.drop_column('stories', 'is_active') - op.drop_column('tasks', 'is_active') diff --git a/storyboard/db/migration/alembic_migrations/versions/004_expand_project_description.py b/storyboard/db/migration/alembic_migrations/versions/004_expand_project_description.py deleted file mode 100644 index f27d18e0..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/004_expand_project_description.py +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Expand project description - -Revision ID: 004 -Revises: 003 -Create Date: 2014-03-05 17:03:12.978207 - -""" - -# revision identifiers, used by Alembic. -revision = '004' -down_revision = '003' - -from alembic import op -import sqlalchemy as sa - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - - op.alter_column( - 'projects', 'description', - type_=sa.UnicodeText) - - -def downgrade(active_plugins=None, options=None): - - op.alter_column( - 'projects', 'description', - type_=sa.Unicode(100)) diff --git a/storyboard/db/migration/alembic_migrations/versions/005_is_active_defaults.py b/storyboard/db/migration/alembic_migrations/versions/005_is_active_defaults.py deleted file mode 100644 index 087e46ab..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/005_is_active_defaults.py +++ /dev/null @@ -1,73 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""empty message - -Revision ID: 005 -Revises: 004 -Create Date: 2014-03-10 14:24:09.622503 - -""" - -# revision identifiers, used by Alembic. -revision = '005' -down_revision = '004' - -from alembic import op -from sqlalchemy import Boolean -from sqlalchemy import Column - - -def upgrade(active_plugins=None, options=None): - op.drop_column('projects', 'is_active') - op.add_column('projects', - Column('is_active', - Boolean(), - default=True, - server_default="1", - nullable=False)) - op.drop_column('stories', 'is_active') - op.add_column('stories', - Column('is_active', - Boolean(), - default=True, - server_default="1", - nullable=False)) - op.drop_column('tasks', 'is_active') - op.add_column('tasks', - Column('is_active', - Boolean(), - default=True, - server_default="1", - nullable=False)) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('projects', 'is_active') - op.add_column('projects', - Column('is_active', - Boolean(), - default=True, - nullable=False)) - op.drop_column('stories', 'is_active') - op.add_column('stories', - Column('is_active', - Boolean(), - default=True, - nullable=False)) - op.drop_column('tasks', 'is_active') - op.add_column('tasks', - Column('is_active', - Boolean(), - default=True, - nullable=False)) diff --git a/storyboard/db/migration/alembic_migrations/versions/006_user_fullname.py b/storyboard/db/migration/alembic_migrations/versions/006_user_fullname.py deleted file mode 100644 index bd1b996d..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/006_user_fullname.py +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Converts the user object to use full_name - -Revision ID: 56bda170aa42 -Revises: 128470dcd02f -Create Date: 2014-03-11 10:45:59.122062 - -""" - -# revision identifiers, used by Alembic. -revision = '006' -down_revision = '005' - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.sql.expression import column -from sqlalchemy.sql.expression import table - - -def upgrade(active_plugins=None, options=None): - op.add_column( - 'users', - sa.Column('full_name', sa.Unicode(255), nullable=True) - ) - - users = table( - 'users', - column('first_name', sa.Unicode(30)), - column('last_name', sa.Unicode(30)), - column('full_name', sa.Unicode(255)) - ) - users.update().values( - {'full_name': column('first_name') + op.inline_literal(' ') + column( - 'last_name')}) - - op.drop_column('users', 'first_name') - op.drop_column('users', 'last_name') - - -def downgrade(active_plugins=None, options=None): - op.add_column( - 'users', - sa.Column('first_name', sa.Unicode(length=30), nullable=True) - ) - op.add_column( - 'users', - sa.Column('last_name', sa.Unicode(length=30), nullable=True) - ) - op.drop_column('users', 'full_name') diff --git a/storyboard/db/migration/alembic_migrations/versions/007_is_active_in_comments.py b/storyboard/db/migration/alembic_migrations/versions/007_is_active_in_comments.py deleted file mode 100644 index 7ac85b27..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/007_is_active_in_comments.py +++ /dev/null @@ -1,41 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""empty message - -Revision ID: 007 -Revises: 006 -Create Date: 2014-04-18 14:55:09.622503 - -""" - -# revision identifiers, used by Alembic. -revision = '007' -down_revision = '006' - -from alembic import op -from sqlalchemy import Boolean -from sqlalchemy import Column - - -def upgrade(active_plugins=None, options=None): - op.add_column('comments', - Column('is_active', - Boolean(), - default=True, - server_default="1", - nullable=False)) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('comments', 'is_active') diff --git a/storyboard/db/migration/alembic_migrations/versions/008_drop_legacy_tables.py b/storyboard/db/migration/alembic_migrations/versions/008_drop_legacy_tables.py deleted file mode 100644 index ae8c5ec0..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/008_drop_legacy_tables.py +++ /dev/null @@ -1,92 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Remove Branch, Milestone tables - -Revision ID: 008 -Revises: 007 -Create Date: 2014-03-19 15:00:39.149963 - -""" - -# revision identifiers, used by Alembic. -revision = '008' -down_revision = '007' - - -from alembic import op -import sqlalchemy as sa - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def _define_enums(): - branch_status = sa.Enum( - 'master', 'release', 'stable', 'unsupported', - name='branch_status') - - return { - 'branch_status': branch_status - } - - -def upgrade(active_plugins=None, options=None): - op.drop_constraint('tasks_ibfk_2', - 'tasks', type_='foreignkey') - op.drop_column('tasks', 'milestone_id') - op.drop_table('milestones') - op.drop_table('branches') - - # Need to explicitly delete enums during migrations for Postgres - enums = _define_enums() - for enum in enums.values(): - enum.drop(op.get_bind()) - - -def downgrade(active_plugins=None, options=None): - enums = _define_enums() - - op.create_table( - 'branches', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('name', sa.String(length=50), nullable=True), - sa.Column('status', enums['branch_status'], nullable=True), - sa.Column('release_date', sa.DateTime(), nullable=True), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('name', name='uniq_branch_name'), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) - op.create_table( - 'milestones', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('name', sa.String(length=50), nullable=True), - sa.Column('branch_id', sa.Integer(), nullable=True), - sa.Column('released', sa.Boolean(), nullable=True), - sa.Column('undefined', sa.Boolean(), nullable=True), - sa.ForeignKeyConstraint(['branch_id'], ['branches.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('name', name='uniq_milestone_name'), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) - op.add_column('tasks', sa.Column('milestone_id', - sa.Integer(), - nullable=True)) - op.create_foreign_key('tasks_ibfk_2', 'tasks', - 'milestones', ['milestone_id'], ['id']) diff --git a/storyboard/db/migration/alembic_migrations/versions/010_remove_legacy_priority.py b/storyboard/db/migration/alembic_migrations/versions/010_remove_legacy_priority.py deleted file mode 100644 index bd8174da..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/010_remove_legacy_priority.py +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Remove legacy priority column - -Revision ID: 010 -Revises: 008 -Create Date: 2014-03-24 14:00:19.159763 - -""" - -# revision identifiers, used by Alembic. -# 009 is skipped on purpose due to a deployment sequencing bug -revision = '010' -down_revision = '008' - - -from alembic import op -import sqlalchemy as sa - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def _define_enums(): - storyboard_priority = sa.Enum( - 'Undefined', 'Low', 'Medium', 'High', 'Critical', - name='priority') - - return { - 'storyboard_priority': storyboard_priority - } - - -def upgrade(active_plugins=None, options=None): - op.drop_column('stories', 'priority') - - # Need to explicitly delete enums during migrations for Postgres - enums = _define_enums() - for enum in enums.values(): - enum.drop(op.get_bind()) - - -def downgrade(active_plugins=None, options=None): - enums = _define_enums() - for enum in enums.values(): - enum.create(op.get_bind()) - - op.add_column('stories', sa.Column('priority', - enums['storyboard_priority'], - nullable=True)) diff --git a/storyboard/db/migration/alembic_migrations/versions/011_authorization_models.py b/storyboard/db/migration/alembic_migrations/versions/011_authorization_models.py deleted file mode 100644 index 471223fa..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/011_authorization_models.py +++ /dev/null @@ -1,74 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Add authorization models - -Revision ID: 011 -Revises: 010 -Create Date: 2014-03-21 17:44:51.248232 - -""" - -# revision identifiers, used by Alembic. -revision = '011' -down_revision = '010' - - -from alembic import op -import sqlalchemy as sa - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - - op.create_table( - 'authorizationcodes', - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('code', sa.Unicode(100), nullable=False), - sa.Column('state', sa.Unicode(100), nullable=False), - sa.Column('user_id', sa.Integer(), nullable=False), - sa.Column('is_active', sa.Boolean(), default=True, server_default="1", - nullable=False), - sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), - sa.PrimaryKeyConstraint('id'), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) - - op.create_table( - 'bearertokens', - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('user_id', sa.Integer(), nullable=False), - sa.Column('access_token', sa.Unicode(100), nullable=False), - sa.Column('refresh_token', sa.Unicode(100), nullable=False), - sa.Column('expires_in', sa.Integer(), nullable=False), - sa.Column('expires_at', sa.DateTime(), nullable=False), - sa.Column('is_active', sa.Boolean(), default=True, server_default="1", - nullable=False), - sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), - sa.PrimaryKeyConstraint('id'), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) - - -def downgrade(active_plugins=None, options=None): - - op.drop_table('bearertokens') - op.drop_table('authorizationcodes') diff --git a/storyboard/db/migration/alembic_migrations/versions/012_task_states.py b/storyboard/db/migration/alembic_migrations/versions/012_task_states.py deleted file mode 100644 index 9f2bea00..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/012_task_states.py +++ /dev/null @@ -1,63 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Update task states - -Revision ID: 011 -Revises: 010 -Create Date: 2014-03-21 17:44:51.248232 - -""" - -# revision identifiers, used by Alembic. -revision = '012' -down_revision = '011' - -from alembic import op -import sqlalchemy as sa - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def _define_enums(): - task_status_old = sa.Enum( - 'Todo', 'In review', 'Landed', - name='task_status') - - task_status_new = sa.Enum( - 'todo', 'inprogress', 'invalid', 'review', 'merged', - name='task_status') - - return { - 'task_status_old': task_status_old, - 'task_status_new': task_status_new - } - - -def upgrade(active_plugins=None, options=None): - enums = _define_enums() - - op.drop_column('tasks', 'status') - op.add_column('tasks', sa.Column('status', - enums['task_status_new'], - nullable=True)) - - -def downgrade(active_plugins=None, options=None): - enums = _define_enums() - - op.drop_column('tasks', 'status') - op.add_column('tasks', sa.Column('status', - enums['task_status_old'], - nullable=True)) diff --git a/storyboard/db/migration/alembic_migrations/versions/013_hard_delete_auth.py b/storyboard/db/migration/alembic_migrations/versions/013_hard_delete_auth.py deleted file mode 100644 index 17620fa1..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/013_hard_delete_auth.py +++ /dev/null @@ -1,102 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Split Access and Refresh tokens to separate tables. -Remove is_active fields as unnecessary. -Expired access tokens and authorization codes will be hard deleted. -Refresh tokens should live forever. - -Revision ID: 013 -Revises: 012 -Create Date: 2014-04-09 13:01:18.536369 - -""" - -# revision identifiers, used by Alembic. -revision = '013' -down_revision = '012' - - -from alembic import op -import sqlalchemy as sa - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - - ### commands auto generated by Alembic - please adjust! ### - op.create_table( - 'accesstokens', - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('user_id', sa.Integer(), nullable=False), - sa.Column('access_token', sa.Unicode(length=100), nullable=False), - sa.Column('expires_in', sa.Integer(), nullable=False), - sa.Column('expires_at', sa.DateTime(), nullable=False), - sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), - sa.PrimaryKeyConstraint('id'), - mysql_default_charset=MYSQL_CHARSET, - mysql_engine=MYSQL_ENGINE) - - op.create_table( - 'refreshtokens', - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('user_id', sa.Integer(), nullable=False), - sa.Column('refresh_token', sa.Unicode(length=100), nullable=False), - sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), - sa.PrimaryKeyConstraint('id'), - mysql_default_charset=MYSQL_CHARSET, - mysql_engine=MYSQL_ENGINE) - - op.drop_table(u'bearertokens') - op.drop_column(u'authorizationcodes', u'is_active') - - ### end Alembic commands ### - - -def downgrade(active_plugins=None, options=None): - - ### commands auto generated by Alembic - please adjust! ### - - op.add_column(u'authorizationcodes', - sa.Column('is_active', sa.Boolean(), default=True, - server_default="1", - nullable=False)) - op.create_table( - u'bearertokens', - sa.Column(u'created_at', sa.DateTime(), nullable=True), - sa.Column(u'updated_at', sa.DateTime(), nullable=True), - sa.Column(u'id', sa.Integer(), nullable=False), - sa.Column(u'user_id', sa.Integer(), nullable=False), - sa.Column(u'access_token', sa.Unicode(length=100), nullable=False), - sa.Column(u'refresh_token', sa.Unicode(length=100), nullable=False), - sa.Column(u'expires_in', sa.Integer(), nullable=False), - sa.Column(u'expires_at', sa.DateTime(), nullable=False), - sa.Column(u'is_active', sa.Column('is_active', sa.Boolean(), - default=True, - server_default="1", - nullable=False)), - sa.ForeignKeyConstraint(['user_id'], [u'users.id'], - name=u'bearertokens_ibfk_1'), - sa.PrimaryKeyConstraint(u'id'), - mysql_default_charset=MYSQL_CHARSET, - mysql_engine=MYSQL_ENGINE) - - op.drop_table('refreshtokens') - op.drop_table('accesstokens') - ### end Alembic commands ### diff --git a/storyboard/db/migration/alembic_migrations/versions/014_hard_delete_tasks.py b/storyboard/db/migration/alembic_migrations/versions/014_hard_delete_tasks.py deleted file mode 100644 index 86ccb562..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/014_hard_delete_tasks.py +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Remove is_active from tasks. - -Revision ID: 014 -Revises: 013 -Create Date: 2014-04-09 16:52:36.375926 - -""" - -# revision identifiers, used by Alembic. -revision = '014' -down_revision = '013' - - -from alembic import op -import sqlalchemy as sa - - -def upgrade(active_plugins=None, options=None): - - ### commands auto generated by Alembic - please adjust! ### - op.drop_column(u'tasks', u'is_active') - - ### end Alembic commands ### - - -def downgrade(active_plugins=None, options=None): - - ### commands auto generated by Alembic - please adjust! ### - - op.add_column(u'tasks', - sa.Column('is_active', sa.Boolean(), default=True, - server_default="1", - nullable=False)) - - ### end Alembic commands ### diff --git a/storyboard/db/migration/alembic_migrations/versions/015_hard_delete_stories.py b/storyboard/db/migration/alembic_migrations/versions/015_hard_delete_stories.py deleted file mode 100644 index 70c6e83b..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/015_hard_delete_stories.py +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Remove is_active from stories. - -Revision ID: 015 -Revises: 014 -Create Date: 2014-04-09 16:52:36.375926 - -""" - -# revision identifiers, used by Alembic. -revision = '015' -down_revision = '014' - - -from alembic import op -import sqlalchemy as sa - - -def upgrade(active_plugins=None, options=None): - - ### commands auto generated by Alembic - please adjust! ### - op.drop_column(u'stories', u'is_active') - - ### end Alembic commands ### - - -def downgrade(active_plugins=None, options=None): - - ### commands auto generated by Alembic - please adjust! ### - - op.add_column(u'stories', - sa.Column('is_active', sa.Boolean(), default=True, - server_default="1", - nullable=False)) - - ### end Alembic commands ### diff --git a/storyboard/db/migration/alembic_migrations/versions/016_task_creator.py b/storyboard/db/migration/alembic_migrations/versions/016_task_creator.py deleted file mode 100644 index ab78d35d..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/016_task_creator.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""We need to know who has created a task. - -Revision ID: 016 -Revises: 015 -Create Date: 2014-04-15 17:16:07.368141 - -""" - -# revision identifiers, used by Alembic. -revision = '016' -down_revision = '015' - - -from alembic import op -import sqlalchemy as sa - - -def upgrade(active_plugins=None, options=None): - - ### commands auto generated by Alembic - please adjust! ### - op.add_column('tasks', - sa.Column('creator_id', sa.Integer(), nullable=True)) - ### end Alembic commands ### - - -def downgrade(active_plugins=None, options=None): - - ### commands auto generated by Alembic - please adjust! ### - op.drop_column('tasks', 'creator_id') - ### end Alembic commands ### diff --git a/storyboard/db/migration/alembic_migrations/versions/017_timeline_events.py b/storyboard/db/migration/alembic_migrations/versions/017_timeline_events.py deleted file mode 100644 index ecb275f9..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/017_timeline_events.py +++ /dev/null @@ -1,129 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Add timeline events. Migrate comments under a new event each. - -Revision ID: 017 -Revises: 016 -Create Date: 2014-04-17 13:05:26.572216 - -""" - -# revision identifiers, used by Alembic. -revision = '017' -down_revision = '016' - - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.sql.expression import table -from sqlalchemy import MetaData, Table - -from storyboard.common import event_types - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - - ### commands auto generated by Alembic - please adjust! ### - op.create_table( - 'events', - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('story_id', sa.Integer(), nullable=True), - sa.Column('comment_id', sa.Integer(), nullable=True), - sa.Column('author_id', sa.Integer(), nullable=True), - sa.Column('event_type', sa.Unicode(length=100), nullable=False), - sa.Column('event_info', sa.UnicodeText(), nullable=True), - sa.PrimaryKeyConstraint('id'), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET) - - bind = op.get_bind() - - comments = list(bind.execute( - sa.select(columns=['*'], from_obj=Table('comments', MetaData())))) - - events_table = table( - 'events', - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('story_id', sa.Integer(), nullable=True), - sa.Column('comment_id', sa.Integer(), nullable=True), - sa.Column('author_id', sa.Integer(), nullable=True), - sa.Column('event_type', sa.Unicode(length=100), nullable=False) - ) - - for comment in comments: - bind.execute(events_table.insert().values( - created_at=comment['created_at'], - event_type=event_types.USER_COMMENT, - comment_id=comment['id'], - story_id=comment['story_id'], - author_id=comment['author_id'] - )) - - op.drop_constraint('comments_ibfk_1', 'comments', type_='foreignkey') - op.drop_constraint('comments_ibfk_2', 'comments', type_='foreignkey') - op.drop_column(u'comments', u'action') - op.drop_column(u'comments', u'story_id') - op.drop_column(u'comments', u'author_id') - op.drop_column(u'comments', u'comment_type') - - ### end Alembic commands ### - - -def downgrade(active_plugins=None, options=None): - - ### commands auto generated by Alembic - please adjust! ### - - op.add_column( - u'comments', - sa.Column(u'comment_type', sa.Unicode(length=20), nullable=True)) - op.add_column( - u'comments', - sa.Column(u'author_id', sa.Integer(), nullable=True)) - op.add_column( - u'comments', - sa.Column(u'story_id', sa.Integer(), nullable=True)) - op.add_column( - u'comments', - sa.Column(u'action', sa.Unicode(length=150), nullable=True)) - - op.create_foreign_key('comments_ibfk_1', 'comments', - 'users', ['author_id'], ['id']) - op.create_foreign_key('comments_ibfk_2', 'comments', - 'stories', ['story_id'], ['id']) - - bind = op.get_bind() - - events = list(bind.execute( - sa.select(columns=['*'], from_obj=Table('events', MetaData())))) - - comments_table = table( - 'comments', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('story_id', sa.Integer(), nullable=True), - sa.Column('author_id', sa.Integer(), nullable=True), - ) - - for event in events: - bind.execute(comments_table.update() - .where(comments_table.c.id == event['comment_id']) - .values(story_id=event['story_id'], - author_id=event['author_id'])) - - op.drop_table('events') - ### end Alembic commands ### diff --git a/storyboard/db/migration/alembic_migrations/versions/018_task_priority.py b/storyboard/db/migration/alembic_migrations/versions/018_task_priority.py deleted file mode 100644 index ea043ffd..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/018_task_priority.py +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Remove story priorities, add task priorities. - -Revision ID: 017 -Revises: 016 -Create Date: 2014-04-15 17:16:07.368141 - -""" - -# revision identifiers, used by Alembic. -revision = '018' -down_revision = '017' - -from alembic import op -import sqlalchemy as sa - - -def _define_enums(): - task_priority = sa.Enum( - 'low', 'medium', 'high', - name='task_priority') - - return { - 'task_priority': task_priority - } - - -def upgrade(active_plugins=None, options=None): - enums = _define_enums() - - op.add_column('tasks', - sa.Column('priority', enums['task_priority'], nullable=True)) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('tasks', 'priority') diff --git a/storyboard/db/migration/alembic_migrations/versions/019_refresh_token_expiration.py b/storyboard/db/migration/alembic_migrations/versions/019_refresh_token_expiration.py deleted file mode 100644 index 2af29785..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/019_refresh_token_expiration.py +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""The refresh token should also have expiration fields. - -Revision ID: 019 -Revises: 018 -Create Date: 2014-05-21 11:17:16.360987 - -""" - -# revision identifiers, used by Alembic. -revision = '019' -down_revision = '018' - - -from alembic import op -import sqlalchemy as sa - - -def upgrade(active_plugins=None, options=None): - - # Deleting old tokens because they don't have a valid expiration - # information. - bind = op.get_bind() - bind.execute(sa.delete(table='refreshtokens')) - - op.add_column('refreshtokens', sa.Column('expires_at', sa.DateTime(), - nullable=False)) - op.add_column('refreshtokens', sa.Column('expires_in', sa.Integer(), - nullable=False)) - ### end Alembic commands ### - - -def downgrade(active_plugins=None, options=None): - - op.drop_column('refreshtokens', 'expires_in') - op.drop_column('refreshtokens', 'expires_at') - ### end Alembic commands ### diff --git a/storyboard/db/migration/alembic_migrations/versions/020_project_names_validation.py b/storyboard/db/migration/alembic_migrations/versions/020_project_names_validation.py deleted file mode 100644 index 5c220a5f..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/020_project_names_validation.py +++ /dev/null @@ -1,80 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Existing projects should be renamed if they do not pass a new validation. -The previous name will be appended to the description so that it can be -restored. - -Revision ID: 020 -Revises: 019 -Create Date: 2014-06-23 12:50:43.924601 - -""" - -# revision identifiers, used by Alembic. -revision = '020' -down_revision = '019' - - -from alembic import op -import sqlalchemy as sa -from sqlalchemy import MetaData -from sqlalchemy.sql.expression import table - -from storyboard.common.custom_types import NameType - - -def upgrade(active_plugins=None, options=None): - - bind = op.get_bind() - validator = NameType() - - projects = list(bind.execute( - sa.select(columns=['*'], from_obj=sa.Table('projects', MetaData())))) - - projects_table = table( - 'projects', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(), nullable=False), - sa.Column('description', sa.UnicodeText(), nullable=True), - ) - - last_idx = 0 - - for project in projects: - project_name = project["name"] - project_id = project["id"] - need_rename = False - - try: - validator.validate(project_name) - except Exception: - need_rename = True - - if need_rename: - # This project needs renaming - temp_name = "Project-%d" % last_idx - last_idx += 1 - updated_description = "%s This project was renamed to fit new " \ - "naming validation. Original name was: %s" \ - % (project["description"], project_name) - - bind.execute(projects_table.update() - .where(projects_table.c.id == project_id) - .values(name=temp_name, - description=updated_description)) - - -def downgrade(active_plugins=None, options=None): - # No way back for invalid names - pass diff --git a/storyboard/db/migration/alembic_migrations/versions/021_subscription.py b/storyboard/db/migration/alembic_migrations/versions/021_subscription.py deleted file mode 100644 index 4f16dade..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/021_subscription.py +++ /dev/null @@ -1,56 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration creates The subscription model primary and secondary tables. - -Revision ID: 021 -Revises: 020 -Create Date: 2014-07-10 15:37:30.662966 - -""" - -# revision identifiers, used by Alembic. -revision = '021' -down_revision = '020' - - -from alembic import op -import sqlalchemy as sa - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - -target_type_enum = sa.Enum('task', 'story', 'project', 'project_group') - - -def upgrade(active_plugins=None, options=None): - - op.create_table( - 'subscriptions', - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('user_id', sa.Integer(), nullable=True), - sa.Column('target_type', target_type_enum, nullable=True), - sa.Column('target_id', sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint('id'), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) - - -def downgrade(active_plugins=None, options=None): - - op.drop_table('subscriptions') - - target_type_enum.drop(op.get_bind()) diff --git a/storyboard/db/migration/alembic_migrations/versions/022_fulltext_indexes.py b/storyboard/db/migration/alembic_migrations/versions/022_fulltext_indexes.py deleted file mode 100644 index 52fb6193..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/022_fulltext_indexes.py +++ /dev/null @@ -1,78 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Adding full text indexes - -Revision ID: 022 -Revises: 021 -Create Date: 2014-07-11 14:08:08.129484 - -""" - -# revision identifiers, used by Alembic. -revision = '022' -down_revision = '021' - - -from alembic import op -from oslo_log import log - -LOG = log.getLogger(__name__) - - -def upgrade(active_plugins=None, options=None): - - version_info = op.get_bind().engine.dialect.server_version_info - if version_info[-1] == "MariaDB": - # Removes fake mysql prefix - version_info = version_info[-4:] - if version_info[0] < 5 or version_info[0] == 5 and version_info[1] < 6: - LOG.warning( - "MySQL version is lower than 5.6. Skipping full-text indexes") - return - - # Index for projects - op.execute("ALTER TABLE projects " - "ADD FULLTEXT projects_fti (name, description)") - - # Index for stories - op.execute("ALTER TABLE stories " - "ADD FULLTEXT stories_fti (title, description)") - - # Index for tasks - op.execute("ALTER TABLE tasks ADD FULLTEXT tasks_fti (title)") - - # Index for comments - op.execute("ALTER TABLE comments ADD FULLTEXT comments_fti (content)") - - # Index for users - op.execute("ALTER TABLE users " - "ADD FULLTEXT users_fti (username, full_name, email)") - - -def downgrade(active_plugins=None, options=None): - - version_info = op.get_bind().engine.dialect.server_version_info - if version_info[-1] == "MariaDB": - # Removes fake mysql prefix - version_info = version_info[-4:] - if version_info[0] < 5 or version_info[0] == 5 and version_info[1] < 6: - LOG.warning( - "MySQL version is lower than 5.6. Skipping full-text indexes") - return - - op.drop_index("projects_fti", table_name='projects') - op.drop_index("stories_fti", table_name='stories') - op.drop_index("tasks_fti", table_name='tasks') - op.drop_index("comments_fti", table_name='comments') - op.drop_index("users_fti", table_name='users') diff --git a/storyboard/db/migration/alembic_migrations/versions/023_story_tags.py b/storyboard/db/migration/alembic_migrations/versions/023_story_tags.py deleted file mode 100644 index cc6e1b22..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/023_story_tags.py +++ /dev/null @@ -1,56 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Add story and tag mapping table. - -Revision ID: 023 -Revises: 022 -Create Date: 2014-08-13 13:47:29.795996 - -""" - -# revision identifiers, used by Alembic. -revision = '023' -down_revision = '022' - - -from alembic import op -import sqlalchemy as sa - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - - ### commands auto generated by Alembic - please adjust! ### - op.create_table('story_storytags', - sa.Column('story_id', sa.Integer(), nullable=True), - sa.Column('storytag_id', sa.Integer(), nullable=True), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) - op.drop_constraint('storytags_ibfk_1', 'storytags', type_='foreignkey') - op.drop_column(u'storytags', u'story_id') - ### end Alembic commands ### - - -def downgrade(active_plugins=None, options=None): - - ### commands auto generated by Alembic - please adjust! ### - op.add_column(u'storytags', - sa.Column('story_id', sa.Integer(), nullable=True)) - op.create_foreign_key('storytags_ibfk_1', 'storytags', - 'stories', ['story_id'], ['id']) - op.drop_table('story_storytags') - ### end Alembic commands ### diff --git a/storyboard/db/migration/alembic_migrations/versions/024_subscription_events.py b/storyboard/db/migration/alembic_migrations/versions/024_subscription_events.py deleted file mode 100644 index 6af87595..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/024_subscription_events.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (c) 2014 Hewlett-Packard Development Company, L.P. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration creates the subscription_events table. - -Revision ID: 024 -Revises: 023 -Create Date: 2014-08-05 15:37:30.662966 - -""" - -# revision identifiers, used by Alembic. -revision = '024' -down_revision = '023' - - -from alembic import op -import sqlalchemy as sa - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - - op.create_table( - 'subscription_events', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('subscriber_id', sa.Integer(), nullable=False), - sa.Column('event_type', sa.Unicode(100), nullable=False), - sa.Column('event_info', sa.UnicodeText(), nullable=True), - sa.PrimaryKeyConstraint('id'), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) - - -def downgrade(active_plugins=None, options=None): - - op.drop_table('subscription_events') diff --git a/storyboard/db/migration/alembic_migrations/versions/025_subscription_event_actor.py b/storyboard/db/migration/alembic_migrations/versions/025_subscription_event_actor.py deleted file mode 100644 index 68191111..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/025_subscription_event_actor.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) 2014 Hewlett-Packard Development Company, L.P. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration adds a column where we can store the ID of the person -who triggered the event. - -Revision ID: 025 -Revises: 024 -Create Date: 2014-09-08 13:21:59.917098 - -""" - -# revision identifiers, used by Alembic. -revision = '025' -down_revision = '024' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(active_plugins=None, options=None): - op.add_column('subscription_events', sa.Column('author_id', sa.Integer())) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('subscription_events', 'author_id') diff --git a/storyboard/db/migration/alembic_migrations/versions/026_expand_story_tags.py b/storyboard/db/migration/alembic_migrations/versions/026_expand_story_tags.py deleted file mode 100644 index 794e34c4..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/026_expand_story_tags.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2014 Hewlett-Packard Development Company, L.P. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration changes length of a valid storytag from 20 to 50 - -Revision ID: 026 -Revises: 025 -Create Date: 2014-09-23 00:00:00 - -""" - -# revision identifiers, used by Alembic. -revision = '026' -down_revision = '025' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(active_plugins=None, options=None): - op.alter_column( - 'storytags', 'name', - type_=sa.String(length=50)) - - -def downgrade(active_plugins=None, options=None): - op.alter_column( - 'storytags', 'name', - type_=sa.String(length=20)) diff --git a/storyboard/db/migration/alembic_migrations/versions/027_disable_login.py b/storyboard/db/migration/alembic_migrations/versions/027_disable_login.py deleted file mode 100644 index 61554807..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/027_disable_login.py +++ /dev/null @@ -1,42 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Adds enable_login flag to users table. - -Revision ID: 027 -Revises: 026 -Create Date: 2014-08-06 01:00:00 - -""" - -# revision identifiers, used by Alembic. -revision = '027' -down_revision = '026' - - -from alembic import op -from sqlalchemy import Boolean -from sqlalchemy import Column - - -def upgrade(active_plugins=None, options=None): - op.add_column('users', - Column('enable_login', - Boolean(), - default=True, - server_default="1", - nullable=False)) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('users', 'enable_login') diff --git a/storyboard/db/migration/alembic_migrations/versions/028_user_preferences.py b/storyboard/db/migration/alembic_migrations/versions/028_user_preferences.py deleted file mode 100644 index c7ffb37f..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/028_user_preferences.py +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Adds a user_preferences table. - -Revision ID: 028 -Revises: 027 -Create Date: 2014-09-14 01:00:00 - -""" - -# revision identifiers, used by Alembic. -revision = '028' -down_revision = '027' - -from alembic import op -import sqlalchemy as sa - -pref_type_enum = sa.Enum('string', 'int', 'bool', 'float') - - -def upgrade(active_plugins=None, options=None): - op.create_table( - 'user_preferences', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('user_id', sa.Integer(), nullable=False), - sa.Column('key', sa.Unicode(100), nullable=False), - sa.Column('type', pref_type_enum, nullable=False), - sa.Column('value', sa.Unicode(255), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - - -def downgrade(active_plugins=None, options=None): - op.drop_table('user_preferences') diff --git a/storyboard/db/migration/alembic_migrations/versions/029_strip_user_constraints.py b/storyboard/db/migration/alembic_migrations/versions/029_strip_user_constraints.py deleted file mode 100644 index a2b824d6..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/029_strip_user_constraints.py +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Remove the user name uniqueness restriction. - -Revision ID: 029 -Revises: 028 -Create Date: 2014-11-10 01:00:00 - -""" - -# revision identifiers, used by Alembic. -revision = '029' -down_revision = '028' - -from alembic import op - - -def upgrade(active_plugins=None, options=None): - op.drop_constraint('uniq_user_username', 'users', type_='unique') - - -def downgrade(active_plugins=None, options=None): - op.create_unique_constraint("uniq_user_username", "users", ["username"]) diff --git a/storyboard/db/migration/alembic_migrations/versions/030_medium_text_comments.py b/storyboard/db/migration/alembic_migrations/versions/030_medium_text_comments.py deleted file mode 100644 index 44928b33..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/030_medium_text_comments.py +++ /dev/null @@ -1,38 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""Modifies the type of the comment content column to be mysql's MEDIUMTEXT -rather than TEXT. This increases the size limit from 2^16 bytes to 2^24 bytes. - -Revision ID: 030 -Revises: 029 -Create Date: 2014-11-12 01:00:00 - -""" - -# revision identifiers, used by Alembic. -revision = '030' -down_revision = '029' - -from alembic import op -import sqlalchemy as sa - -from storyboard.db.models import MYSQL_MEDIUM_TEXT - - -def upgrade(active_plugins=None, options=None): - op.alter_column('comments', 'content', type_=MYSQL_MEDIUM_TEXT) - - -def downgrade(active_plugins=None, options=None): - op.alter_column('comments', 'content', type_=sa.UnicodeText) diff --git a/storyboard/db/migration/alembic_migrations/versions/031_resize_fields.py b/storyboard/db/migration/alembic_migrations/versions/031_resize_fields.py deleted file mode 100644 index 25ed5105..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/031_resize_fields.py +++ /dev/null @@ -1,41 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration resize fields in project_groups, stories ans tasks - -Revision ID: 031 -Revises: 030 -Create Date: 2014-12-24 01:00:00 - -""" - -# revision identifiers, used by Alembic. -revision = '031' -down_revision = '030' - -import sqlalchemy as sa - -from alembic import op - - -def upgrade(active_plugins=None, options=None): - - op.alter_column('project_groups', 'title', type_=sa.Unicode(255)) - op.alter_column('stories', 'title', type_=sa.Unicode(255)) - op.alter_column('tasks', 'title', type_=sa.Unicode(255)) - - -def downgrade(active_plugins=None, options=None): - op.alter_column('project_groups', 'title', type_=sa.Unicode(100)) - op.alter_column('stories', 'title', type_=sa.Unicode(100)) - op.alter_column('tasks', 'title', type_=sa.Unicode(100)) diff --git a/storyboard/db/migration/alembic_migrations/versions/032_repo_url.py b/storyboard/db/migration/alembic_migrations/versions/032_repo_url.py deleted file mode 100644 index f6d14cca..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/032_repo_url.py +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration adds new column for git repo to projects table - -Revision ID: 031 -Revises: 030 -Create Date: 2014-12-30 14:55:09.622503 - -""" - -# revision identifiers, used by Alembic. - -revision = '032' -down_revision = '031' - -from alembic import op -from sqlalchemy import Column -from sqlalchemy import String - - -def upgrade(active_plugins=None, options=None): - op.add_column('projects', Column('repo_url', - String(255), - default=None, - nullable=True)) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('projects', 'repo_url') diff --git a/storyboard/db/migration/alembic_migrations/versions/033_authorization_token_ttl.py b/storyboard/db/migration/alembic_migrations/versions/033_authorization_token_ttl.py deleted file mode 100644 index 1a2a637a..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/033_authorization_token_ttl.py +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration adds an expires_in column to the authorizationcodes table. - -Revision ID: 033 -Revises: 032 -Create Date: 2015-02-04 12:00:00 - -""" - -# revision identifiers, used by Alembic. - -revision = '033' -down_revision = '032' - -from alembic import op -from sqlalchemy import Column -from sqlalchemy import Integer - - -def upgrade(active_plugins=None, options=None): - op.add_column('authorizationcodes', Column('expires_in', - Integer(), - nullable=False)) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('authorizationcodes', 'expires_in') diff --git a/storyboard/db/migration/alembic_migrations/versions/034_refresh_access_token_reference.py b/storyboard/db/migration/alembic_migrations/versions/034_refresh_access_token_reference.py deleted file mode 100644 index 42fa7958..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/034_refresh_access_token_reference.py +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration creates a reference between oauth access tokens and refresh -tokens. - -Revision ID: 034 -Revises: 033 -Create Date: 2015-02-06 12:00:00 - -""" - -# revision identifiers, used by Alembic. - -revision = '034' -down_revision = '033' - -from alembic import op -from sqlalchemy import Column -from sqlalchemy import Integer - - -def upgrade(active_plugins=None, options=None): - op.add_column('refreshtokens', Column('access_token_id', - Integer(), - nullable=False)) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('refreshtokens', 'access_token_id') diff --git a/storyboard/db/migration/alembic_migrations/versions/035_projects_autocreate_branches.py b/storyboard/db/migration/alembic_migrations/versions/035_projects_autocreate_branches.py deleted file mode 100644 index be80a9bc..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/035_projects_autocreate_branches.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (c) 2015 Mirantis Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration adds new column for autocreate branches and makes it 'false' -in all projects in database. - -Revision ID: 035 -Revises: 034 -Create Date: 2015-01-26 13:00:02.622503 - -""" - -# revision identifiers, used by Alembic. - -revision = '035' -down_revision = '034' - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.sql.expression import table - - -def upgrade(active_plugins=None, options=None): - op.add_column('projects', sa.Column('autocreate_branches', - sa.Boolean(), - default=False)) - - projects_table = table( - 'projects', - sa.Column('autocreate_branches', sa.Boolean(), nullable=True) - ) - - bind = op.get_bind() - bind.execute(projects_table.update(). - values(autocreate_branches=False)) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('projects', 'autocreate_branches') diff --git a/storyboard/db/migration/alembic_migrations/versions/036_branches_table.py b/storyboard/db/migration/alembic_migrations/versions/036_branches_table.py deleted file mode 100644 index eea019c4..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/036_branches_table.py +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright (c) 2015 Mirantis Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration adds new table for branches and for all projects in database -adds branch with name 'master'. - -Revision ID: 036 -Revises: 035 -Create Date: 2015-01-26 13:03:34.622503 - -""" - -# revision identifiers, used by Alembic. - -revision = '036' -down_revision = '035' - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.sql.expression import table - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - op.create_table( - 'branches', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(100), nullable=True), - sa.Column('project_id', sa.Integer(), nullable=True), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('expired', sa.Boolean(), default=False, nullable=True), - sa.Column('expiration_date', sa.DateTime(), default=None, - nullable=True), - sa.Column('autocreated', sa.Boolean(), default=False, nullable=True), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('name', 'project_id', name="branch_un_constr"), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) - - bind = op.get_bind() - - projects = list(bind.execute( - sa.select(columns=['id', 'created_at', 'updated_at'], - from_obj=sa.Table('projects', sa.MetaData())))) - - branches_table = table( - 'branches', - sa.Column('name', sa.String(100), nullable=True), - sa.Column('project_id', sa.Integer(), nullable=True), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('expired', sa.Boolean(), default=False), - sa.Column('expiration_date', sa.DateTime(), default=None), - sa.Column('autocreated', sa.Boolean(), default=False), - ) - - for project in projects: - bind.execute(branches_table.insert().values( - name="master", - project_id=project['id'], - created_at=project['created_at'], - updated_at=project['updated_at'] - )) - - -def downgrade(active_plugins=None, options=None): - op.drop_table('branches') diff --git a/storyboard/db/migration/alembic_migrations/versions/037_branch_id_in_tasks.py b/storyboard/db/migration/alembic_migrations/versions/037_branch_id_in_tasks.py deleted file mode 100644 index 5c05008e..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/037_branch_id_in_tasks.py +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright (c) 2015 Mirantis Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration adds new column for branch id and merge all tasks to branch -'master' in corresponding project. - -Revision ID: 037 -Revises: 036 -Create Date: 2015-01-27 13:17:34.622503 - -""" - -# revision identifiers, used by Alembic. - -revision = '037' -down_revision = '036' - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.sql.expression import table - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - op.add_column( - 'tasks', - sa.Column('branch_id', sa.Integer(), nullable=True) - ) - - bind = op.get_bind() - - branches = list(bind.execute( - sa.select(columns=['id', 'name', 'project_id'], - from_obj=sa.Table('branches', sa.MetaData())))) - - projects = list(bind.execute( - sa.select(columns=['id'], from_obj=sa.Table('projects', - sa.MetaData())))) - branch_dict = {} - - for branch in branches: - branch_dict[(branch['project_id'], branch['name'])] = branch['id'] - - tasks_table = table( - 'tasks', - sa.Column('project_id', sa.Integer(), nullable=True), - sa.Column('branch_id', sa.Integer(), nullable=True) - ) - - for project in projects: - bind.execute( - tasks_table.update(). - where(tasks_table.c.project_id == project['id']). - values(branch_id=branch_dict[(project['id'], "master")]) - ) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('tasks', 'branch_id') diff --git a/storyboard/db/migration/alembic_migrations/versions/038_milestones.py b/storyboard/db/migration/alembic_migrations/versions/038_milestones.py deleted file mode 100644 index 0ad34a5d..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/038_milestones.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (c) 2015 Mirantis Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration adds milestones table. - -Revision ID: 038 -Revises: 037 -Create Date: 2015-01-28 15:26:34.622503 - -""" - -# revision identifiers, used by Alembic. - -revision = '038' -down_revision = '037' - -from alembic import op -import sqlalchemy as sa - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - op.create_table( - 'milestones', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(100), nullable=True), - sa.Column('branch_id', sa.Integer(), nullable=True), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('expired', sa.Boolean(), default=False, nullable=True), - sa.Column('expiration_date', sa.DateTime(), default=None), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('name', 'branch_id', name="milestone_un_constr"), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) - - -def downgrade(active_plugins=None, options=None): - op.drop_table('milestones') diff --git a/storyboard/db/migration/alembic_migrations/versions/039_milestone_id_in_tasks.py b/storyboard/db/migration/alembic_migrations/versions/039_milestone_id_in_tasks.py deleted file mode 100644 index fd075edb..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/039_milestone_id_in_tasks.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2015 Mirantis Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration adds new column for milestone id. - -Revision ID: 039 -Revises: 038 -Create Date: 2015-01-27 13:17:34.622503 - -""" - -# revision identifiers, used by Alembic. - -revision = '039' -down_revision = '038' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(active_plugins=None, options=None): - op.add_column( - 'tasks', - sa.Column('milestone_id', sa.Integer(), nullable=True) - ) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('tasks', 'milestone_id') diff --git a/storyboard/db/migration/alembic_migrations/versions/040_create_accesstoken_index.py b/storyboard/db/migration/alembic_migrations/versions/040_create_accesstoken_index.py deleted file mode 100644 index c8aca88f..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/040_create_accesstoken_index.py +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration creates a new index on accesstokens table -for the access_token column. - -Revision ID: 040 -Revises: 039 -Create Date: 2015-02-17 12:00:00 - -""" - -# revision identifiers, used by Alembic. - -revision = '040' -down_revision = '039' - -from alembic import op - - -def upgrade(active_plugins=None, options=None): - op.create_index('accesstokens_access_token_idx', - 'accesstokens', ['access_token']) - - -def downgrade(active_plugins=None, options=None): - op.drop_index('accesstokens_access_token_idx') diff --git a/storyboard/db/migration/alembic_migrations/versions/041_refresh_access_tokens.py b/storyboard/db/migration/alembic_migrations/versions/041_refresh_access_tokens.py deleted file mode 100644 index 605245a7..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/041_refresh_access_tokens.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration creates new table for relations between access and refresh -tokens. - -Revision ID: 041 -Revises: 040 -Create Date: 2015-02-18 18:03:23 - -""" - -# revision identifiers, used by Alembic. - -revision = '041' -down_revision = '040' - -from alembic import op -import sqlalchemy as sa - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - op.create_table('access_refresh_tokens', - sa.Column('access_token_id', sa.Integer(), nullable=False), - sa.Column('refresh_token_id', sa.Integer(), - nullable=False), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) - op.drop_column(u'refreshtokens', u'access_token_id') - - -def downgrade(active_plugins=None, options=None): - op.add_column('refreshtokens', sa.Column('access_token_id', - sa.Integer(), - nullable=False)) - op.drop_table('access_refresh_tokens') diff --git a/storyboard/db/migration/alembic_migrations/versions/042_remove_nick.py b/storyboard/db/migration/alembic_migrations/versions/042_remove_nick.py deleted file mode 100644 index f6d0dd97..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/042_remove_nick.py +++ /dev/null @@ -1,71 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration removes the 'nickname' column from the user table. - -Revision ID: 042 -Revises: 041 -Create Date: 2015-02-17 12:00:00 - -""" - -# revision identifiers, used by Alembic. - -revision = '042' -down_revision = '041' - -from alembic import op -from oslo_log import log -import sqlalchemy as sa - -LOG = log.getLogger(__name__) - - -def upgrade(active_plugins=None, options=None): - op.drop_column('users', 'username') - - # Handle the FT Index on the user table. - version_info = op.get_bind().engine.dialect.server_version_info - if version_info[-1] == "MariaDB": - # Removes fake mysql prefix - version_info = version_info[-4:] - if version_info[0] < 5 or version_info[0] == 5 and version_info[1] < 6: - LOG.warning( - "MySQL version is lower than 5.6. Skipping full-text indexes") - return - - # Index for users - op.drop_index("users_fti", table_name='users') - op.execute("ALTER TABLE users " - "ADD FULLTEXT users_fti (full_name, email)") - - -def downgrade(active_plugins=None, options=None): - op.add_column( - 'users', - sa.Column('username', sa.Unicode(length=30), nullable=True), - ) - - version_info = op.get_bind().engine.dialect.server_version_info - if version_info[-1] == "MariaDB": - # Removes fake mysql prefix - version_info = version_info[-4:] - if version_info[0] < 5 or version_info[0] == 5 and version_info[1] < 6: - LOG.warning( - "MySQL version is lower than 5.6. Skipping full-text indexes") - return - - # Index for users - op.drop_index("users_fti", table_name='users') - op.execute("ALTER TABLE users " - "ADD FULLTEXT users_fti (username, full_name, email)") diff --git a/storyboard/db/migration/alembic_migrations/versions/043_fix_tasks.py b/storyboard/db/migration/alembic_migrations/versions/043_fix_tasks.py deleted file mode 100644 index 46801950..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/043_fix_tasks.py +++ /dev/null @@ -1,72 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration fix project_id and branch_id fields in tasks. All tasks -without project id now are assigned to project with the smallest id. All tasks -without branch_id now assigned to masted branch of matching project. - -Revision ID: 043 -Revises: 042 -Create Date: 2015-03-24 13:11:22 - -""" - -# revision identifiers, used by Alembic. - -revision = '043' -down_revision = '042' - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.sql.expression import table - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - bind = op.get_bind() - - branches = list(bind.execute( - sa.select(columns=['id', 'name', 'project_id'], - from_obj=sa.Table('branches', sa.MetaData())))) - - projects = list(bind.execute( - sa.select(columns=['id'], from_obj=sa.Table('projects', - sa.MetaData())))) - if len(projects) > 0: - branch_dict = {} - - for branch in branches: - branch_dict[(branch['project_id'], branch['name'])] = branch['id'] - - tasks_table = table( - 'tasks', - sa.Column('project_id', sa.Integer(), nullable=True), - sa.Column('branch_id', sa.Integer(), nullable=True), - ) - - bind.execute(tasks_table.update(). - where(tasks_table.c.project_id.is_(None)). - values(project_id=projects[0].id)) - - for project in projects: - bind.execute( - tasks_table.update(). - where(tasks_table.c.project_id == project['id']). - values(branch_id=branch_dict[(project['id'], "master")]) - ) - - -def downgrade(active_plugins=None, options=None): - pass diff --git a/storyboard/db/migration/alembic_migrations/versions/044_story_types.py b/storyboard/db/migration/alembic_migrations/versions/044_story_types.py deleted file mode 100644 index aaa91aae..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/044_story_types.py +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright (c) 2015 Mirantis Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration adds story types table. - -Revision ID: 044 -Revises: 043 -Create Date: 2015-03-10 14:52:55.783625 - -""" - -# revision identifiers, used by Alembic. - -revision = '044' -down_revision = '043' - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.sql.expression import table - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - op.create_table( - 'story_types', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.Column('name', sa.String(50), nullable=True), - sa.Column('icon', sa.String(50), nullable=True), - sa.Column('restricted', sa.Boolean(), default=False), - sa.Column('private', sa.Boolean(), default=False), - sa.Column('visible', sa.Boolean(), default=True), - sa.PrimaryKeyConstraint('id'), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) - - bind = op.get_bind() - - story_types_table = table( - 'story_types', - sa.Column('name', sa.String(50), nullable=True), - sa.Column('icon', sa.String(50), nullable=True), - sa.Column('restricted', sa.Boolean(), default=False), - sa.Column('private', sa.Boolean(), default=False), - sa.Column('visible', sa.Boolean(), default=True), - ) - - bind.execute(story_types_table.insert().values( - name='bug', - icon='fa-bug' - )) - - bind.execute(story_types_table.insert().values( - name='feature', - icon='fa-lightbulb-o', - restricted=True - )) - - bind.execute(story_types_table.insert().values( - name='private_vulnerability', - icon='fa-lock', - private=True - )) - - bind.execute(story_types_table.insert().values( - name='public_vulnerability', - icon='fa-bomb', - visible=False - )) - - -def downgrade(active_plugins=None, options=None): - op.drop_table('story_types') diff --git a/storyboard/db/migration/alembic_migrations/versions/045_story_type_id.py b/storyboard/db/migration/alembic_migrations/versions/045_story_type_id.py deleted file mode 100644 index be26f520..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/045_story_type_id.py +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (c) 2015 Mirantis Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration adds story type id to stories table and sets story type id -to 1 (bugs) in all stories. - -Revision ID: 045 -Revises: 044 -Create Date: 2015-03-10 15:23:54.723124 - -""" - -# revision identifiers, used by Alembic. - -revision = '045' -down_revision = '044' - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.sql.expression import table - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - op.add_column( - 'stories', - sa.Column('story_type_id', sa.Integer(), default=1) - ) - - bind = op.get_bind() - - stories_table = table( - 'stories', - sa.Column('story_type_id', sa.Integer(), default=1) - ) - - bind.execute(stories_table.update().values(story_type_id=1)) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('stories', 'story_type_id') diff --git a/storyboard/db/migration/alembic_migrations/versions/046_branches_restricted.py b/storyboard/db/migration/alembic_migrations/versions/046_branches_restricted.py deleted file mode 100644 index cf653028..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/046_branches_restricted.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (c) 2015 Mirantis Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration adds restricted field to branches table and sets this field -to True in branches with name 'master'. - -Revision ID: 046 -Revises: 045 -Create Date: 2015-03-10 15:23:54.723124 - -""" - -# revision identifiers, used by Alembic. - -revision = '046' -down_revision = '045' - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.sql.expression import table - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - op.add_column( - 'branches', - sa.Column('restricted', sa.Boolean(), default=False) - ) - - bind = op.get_bind() - - branches_table = table( - 'branches', - sa.Column('name', sa.String(100), nullable=True), - sa.Column('restricted', sa.Boolean(), default=False) - ) - - bind.execute( - branches_table.update().where( - branches_table.c.name != 'master' - ).values(restricted=False) - ) - - bind.execute( - branches_table.update().where( - branches_table.c.name == 'master' - ).values(restricted=True) - ) - - -def downgrade(active_plugins=None, options=None): - op.drop_column('branches', 'restricted') diff --git a/storyboard/db/migration/alembic_migrations/versions/047_may_mutate_to.py b/storyboard/db/migration/alembic_migrations/versions/047_may_mutate_to.py deleted file mode 100644 index 636bae44..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/047_may_mutate_to.py +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (c) 2015 Mirantis Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration adds may_mutate_to table. - -Revision ID: 047 -Revises: 046 -Create Date: 2015-03-10 17:47:34.395641 - -""" - -# revision identifiers, used by Alembic. - -revision = '047' -down_revision = '046' - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.sql.expression import table - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - op.create_table( - 'may_mutate_to', - sa.Column('story_type_id_from', sa.Integer(), nullable=False), - sa.Column('story_type_id_to', sa.Integer(), nullable=False), - sa.UniqueConstraint('story_type_id_from', - 'story_type_id_to', - name="mutate_un_constr"), - sa.PrimaryKeyConstraint(), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) - - bind = op.get_bind() - - story_types_table = table( - 'may_mutate_to', - sa.Column('story_type_id_from', sa.Integer(), nullable=False), - sa.Column('story_type_id_to', sa.Integer(), nullable=False), - ) - - bind.execute(story_types_table.insert().values( - story_type_id_from=1, - story_type_id_to=4 - )) - - bind.execute(story_types_table.insert().values( - story_type_id_from=1, - story_type_id_to=2 - )) - - bind.execute(story_types_table.insert().values( - story_type_id_from=2, - story_type_id_to=1 - )) - - bind.execute(story_types_table.insert().values( - story_type_id_from=3, - story_type_id_to=4 - )) - - bind.execute(story_types_table.insert().values( - story_type_id_from=3, - story_type_id_to=1 - )) - - bind.execute(story_types_table.insert().values( - story_type_id_from=4, - story_type_id_to=1 - )) - - -def downgrade(active_plugins=None, options=None): - op.drop_table('may_mutate_to') diff --git a/storyboard/db/migration/alembic_migrations/versions/048_refresh_access_token_link.py b/storyboard/db/migration/alembic_migrations/versions/048_refresh_access_token_link.py deleted file mode 100644 index dbeb0efc..00000000 --- a/storyboard/db/migration/alembic_migrations/versions/048_refresh_access_token_link.py +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""This migration converts our many-to-many mapping among auth tokens into -a one-to-one relationship. - -Revision ID: 048 -Revises: 047 -Create Date: 2015-04-12 18:03:23 - -""" - -# revision identifiers, used by Alembic. - -revision = '048' -down_revision = '047' - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.sql.expression import table - -MYSQL_ENGINE = 'InnoDB' -MYSQL_CHARSET = 'utf8' - - -def upgrade(active_plugins=None, options=None): - op.add_column('refreshtokens', sa.Column('access_token_id', - sa.Integer(), - nullable=False)) - op.drop_table('access_refresh_tokens') - - # Delete all refresh and access tokens, as the relationship is no longer - # valid. - bind = op.get_bind() - - refresh_table = table( - 'refreshtokens' - ) - access_table = table( - 'accesstokens' - ) - - bind.execute(refresh_table.delete()) - bind.execute(access_table.delete()) - - -def downgrade(active_plugins=None, options=None): - op.create_table('access_refresh_tokens', - sa.Column('access_token_id', sa.Integer(), nullable=False), - sa.Column('refresh_token_id', sa.Integer(), - nullable=False), - mysql_engine=MYSQL_ENGINE, - mysql_charset=MYSQL_CHARSET - ) - op.drop_column(u'refreshtokens', u'access_token_id') diff --git a/storyboard/db/migration/alembic_migrations/versions/049_add_tables_for_worklists_and_boards.py b/storyboard/db/migration/alembic_migrations/versions/049_add_tables_for_worklists_and_boards.py index 6046f93d..f297f3ce 100644 --- a/storyboard/db/migration/alembic_migrations/versions/049_add_tables_for_worklists_and_boards.py +++ b/storyboard/db/migration/alembic_migrations/versions/049_add_tables_for_worklists_and_boards.py @@ -14,14 +14,14 @@ """Add tables for worklists and boards Revision ID: 049 -Revises: 048 +Revises: 001 Create Date: 2015-08-17 12:17:35.629353 """ # revision identifiers, used by Alembic. revision = '049' -down_revision = '048' +down_revision = '001' from alembic import op