Merge "skip some alembic migrations for sqlite"
This commit is contained in:
commit
4b76f61e74
@ -61,337 +61,345 @@ def _define_enums():
|
|||||||
|
|
||||||
|
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
|
dialect = op.get_bind().engine.dialect
|
||||||
enums = _define_enums()
|
enums = _define_enums()
|
||||||
|
|
||||||
op.create_table(
|
if dialect.supports_alter:
|
||||||
'project_groups',
|
op.create_table(
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
'project_groups',
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('name', sa.String(length=50), nullable=True),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('title', sa.Unicode(length=255), nullable=True),
|
sa.Column('name', sa.String(length=50), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('title', sa.Unicode(length=255), nullable=True),
|
||||||
sa.UniqueConstraint('name', name='uniq_group_name'),
|
sa.PrimaryKeyConstraint('id'),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.UniqueConstraint('name', name='uniq_group_name'),
|
||||||
mysql_charset=MYSQL_CHARSET
|
mysql_engine=MYSQL_ENGINE,
|
||||||
)
|
mysql_charset=MYSQL_CHARSET
|
||||||
op.create_table(
|
)
|
||||||
'user_preferences',
|
op.create_table(
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
'user_preferences',
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('key', sa.Unicode(100), nullable=False),
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||||
sa.Column('type', enums['pref_type'], nullable=False),
|
sa.Column('key', sa.Unicode(100), nullable=False),
|
||||||
sa.Column('value', sa.Unicode(255), nullable=False),
|
sa.Column('type', enums['pref_type'], nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id')
|
sa.Column('value', sa.Unicode(255), nullable=False),
|
||||||
)
|
sa.PrimaryKeyConstraint('id')
|
||||||
op.create_table(
|
)
|
||||||
'users',
|
op.create_table(
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
'users',
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('full_name', sa.Unicode(255), nullable=True),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('email', sa.String(length=255), nullable=True),
|
sa.Column('full_name', sa.Unicode(255), nullable=True),
|
||||||
sa.Column('openid', sa.String(255)),
|
sa.Column('email', sa.String(length=255), nullable=True),
|
||||||
sa.Column('is_staff', sa.Boolean(), nullable=True),
|
sa.Column('openid', sa.String(255)),
|
||||||
sa.Column('is_active', sa.Boolean(), nullable=True),
|
sa.Column('is_staff', sa.Boolean(), nullable=True),
|
||||||
sa.Column('is_superuser', sa.Boolean(), nullable=True),
|
sa.Column('is_active', sa.Boolean(), nullable=True),
|
||||||
sa.Column('last_login', sa.DateTime(), nullable=True),
|
sa.Column('is_superuser', sa.Boolean(), nullable=True),
|
||||||
sa.Column('enable_login', sa.Boolean(), default=True,
|
sa.Column('last_login', sa.DateTime(), nullable=True),
|
||||||
server_default="1", nullable=False),
|
sa.Column('enable_login', sa.Boolean(), default=True,
|
||||||
sa.PrimaryKeyConstraint('id'),
|
server_default="1", nullable=False),
|
||||||
sa.UniqueConstraint('email', name='uniq_user_email'),
|
sa.PrimaryKeyConstraint('id'),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.UniqueConstraint('email', name='uniq_user_email'),
|
||||||
mysql_charset=MYSQL_CHARSET
|
mysql_engine=MYSQL_ENGINE,
|
||||||
)
|
mysql_charset=MYSQL_CHARSET
|
||||||
op.create_table(
|
)
|
||||||
'teams',
|
op.create_table(
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
'teams',
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('name', sa.Unicode(length=255), nullable=True),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('name', sa.Unicode(length=255), nullable=True),
|
||||||
sa.UniqueConstraint('name', name='uniq_team_name'),
|
sa.PrimaryKeyConstraint('id'),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.UniqueConstraint('name', name='uniq_team_name'),
|
||||||
mysql_charset=MYSQL_CHARSET
|
mysql_engine=MYSQL_ENGINE,
|
||||||
)
|
mysql_charset=MYSQL_CHARSET
|
||||||
op.create_table(
|
)
|
||||||
'permissions',
|
op.create_table(
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
'permissions',
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('name', sa.Unicode(length=50), nullable=True),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('codename', sa.Unicode(length=255), nullable=True),
|
sa.Column('name', sa.Unicode(length=50), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('codename', sa.Unicode(length=255), nullable=True),
|
||||||
sa.UniqueConstraint('name', name='uniq_permission_name'),
|
sa.PrimaryKeyConstraint('id'),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.UniqueConstraint('name', name='uniq_permission_name'),
|
||||||
mysql_charset=MYSQL_CHARSET
|
mysql_engine=MYSQL_ENGINE,
|
||||||
)
|
mysql_charset=MYSQL_CHARSET
|
||||||
op.create_table(
|
)
|
||||||
'team_membership',
|
op.create_table(
|
||||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
'team_membership',
|
||||||
sa.Column('team_id', sa.Integer(), nullable=True),
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
|
sa.Column('team_id', sa.Integer(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
|
||||||
sa.PrimaryKeyConstraint(),
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.PrimaryKeyConstraint(),
|
||||||
mysql_charset=MYSQL_CHARSET
|
mysql_engine=MYSQL_ENGINE,
|
||||||
)
|
mysql_charset=MYSQL_CHARSET
|
||||||
op.create_table(
|
)
|
||||||
'user_permissions',
|
op.create_table(
|
||||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
'user_permissions',
|
||||||
sa.Column('permission_id', sa.Integer(), nullable=True),
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['permission_id'], ['permissions.id'], ),
|
sa.Column('permission_id', sa.Integer(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
sa.ForeignKeyConstraint(['permission_id'], ['permissions.id'], ),
|
||||||
sa.PrimaryKeyConstraint(),
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.PrimaryKeyConstraint(),
|
||||||
mysql_charset=MYSQL_CHARSET
|
mysql_engine=MYSQL_ENGINE,
|
||||||
)
|
mysql_charset=MYSQL_CHARSET
|
||||||
op.create_table(
|
)
|
||||||
'team_permissions',
|
op.create_table(
|
||||||
sa.Column('permission_id', sa.Integer(), nullable=True),
|
'team_permissions',
|
||||||
sa.Column('team_id', sa.Integer(), nullable=True),
|
sa.Column('permission_id', sa.Integer(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
|
sa.Column('team_id', sa.Integer(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['permission_id'], ['permissions.id'], ),
|
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
|
||||||
sa.PrimaryKeyConstraint(),
|
sa.ForeignKeyConstraint(['permission_id'], ['permissions.id'], ),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.PrimaryKeyConstraint(),
|
||||||
mysql_charset=MYSQL_CHARSET
|
mysql_engine=MYSQL_ENGINE,
|
||||||
)
|
mysql_charset=MYSQL_CHARSET
|
||||||
op.create_table(
|
)
|
||||||
'stories',
|
op.create_table(
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
'stories',
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('creator_id', sa.Integer(), nullable=True),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('title', sa.Unicode(length=255), nullable=True),
|
sa.Column('creator_id', sa.Integer(), nullable=True),
|
||||||
sa.Column('description', sa.UnicodeText(), nullable=True),
|
sa.Column('title', sa.Unicode(length=255), nullable=True),
|
||||||
sa.Column('is_bug', sa.Boolean(), nullable=True),
|
sa.Column('description', sa.UnicodeText(), nullable=True),
|
||||||
sa.Column('story_type_id', sa.Integer(), default=1),
|
sa.Column('is_bug', sa.Boolean(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['creator_id'], ['users.id'], ),
|
sa.Column('story_type_id', sa.Integer(), default=1),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.ForeignKeyConstraint(['creator_id'], ['users.id'], ),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.PrimaryKeyConstraint('id'),
|
||||||
mysql_charset=MYSQL_CHARSET
|
mysql_engine=MYSQL_ENGINE,
|
||||||
)
|
mysql_charset=MYSQL_CHARSET
|
||||||
op.create_table(
|
)
|
||||||
'projects',
|
op.create_table(
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
'projects',
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('name', sa.String(length=50), nullable=True),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('description', sa.UnicodeText(), nullable=True),
|
sa.Column('name', sa.String(length=50), nullable=True),
|
||||||
sa.Column('team_id', sa.Integer(), nullable=True),
|
sa.Column('description', sa.UnicodeText(), nullable=True),
|
||||||
sa.Column('is_active', sa.Boolean(), default=True,
|
sa.Column('team_id', sa.Integer(), nullable=True),
|
||||||
server_default='1', nullable=False),
|
sa.Column('is_active', sa.Boolean(), default=True,
|
||||||
sa.Column('repo_url', sa.String(255), default=None, nullable=True),
|
server_default='1', nullable=False),
|
||||||
sa.Column('autocreate_branches', sa.Boolean(), default=False),
|
sa.Column('repo_url', sa.String(255), default=None, nullable=True),
|
||||||
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
|
sa.Column('autocreate_branches', sa.Boolean(), default=False),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
|
||||||
sa.UniqueConstraint('name', name='uniq_project_name'),
|
sa.PrimaryKeyConstraint('id'),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.UniqueConstraint('name', name='uniq_project_name'),
|
||||||
mysql_charset=MYSQL_CHARSET
|
mysql_engine=MYSQL_ENGINE,
|
||||||
)
|
mysql_charset=MYSQL_CHARSET
|
||||||
op.create_table(
|
)
|
||||||
'project_group_mapping',
|
op.create_table(
|
||||||
sa.Column('project_id', sa.Integer(), nullable=True),
|
'project_group_mapping',
|
||||||
sa.Column('project_group_id', sa.Integer(), nullable=True),
|
sa.Column('project_id', sa.Integer(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['project_group_id'], ['project_groups.id'], ),
|
sa.Column('project_group_id', sa.Integer(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ),
|
sa.ForeignKeyConstraint(
|
||||||
sa.PrimaryKeyConstraint(),
|
['project_group_id'],
|
||||||
mysql_engine=MYSQL_ENGINE,
|
['project_groups.id'],
|
||||||
mysql_charset=MYSQL_CHARSET
|
),
|
||||||
)
|
sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ),
|
||||||
op.create_table(
|
sa.PrimaryKeyConstraint(),
|
||||||
'tasks',
|
mysql_engine=MYSQL_ENGINE,
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
mysql_charset=MYSQL_CHARSET
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
)
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
op.create_table(
|
||||||
sa.Column('title', sa.Unicode(length=255), nullable=True),
|
'tasks',
|
||||||
sa.Column('status', enums['task_status'], nullable=True),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('story_id', sa.Integer(), nullable=True),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('project_id', sa.Integer(), nullable=True),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('assignee_id', sa.Integer(), nullable=True),
|
sa.Column('title', sa.Unicode(length=255), nullable=True),
|
||||||
sa.Column('creator_id', sa.Integer(), nullable=True),
|
sa.Column('status', enums['task_status'], nullable=True),
|
||||||
sa.Column('priority', enums['task_priority'], nullable=True),
|
sa.Column('story_id', sa.Integer(), nullable=True),
|
||||||
sa.Column('branch_id', sa.Integer(), nullable=True),
|
sa.Column('project_id', sa.Integer(), nullable=True),
|
||||||
sa.Column('milestone_id', sa.Integer(), nullable=True),
|
sa.Column('assignee_id', sa.Integer(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['assignee_id'], ['users.id'],
|
sa.Column('creator_id', sa.Integer(), nullable=True),
|
||||||
name='tasks_ibfk_1'),
|
sa.Column('priority', enums['task_priority'], nullable=True),
|
||||||
sa.ForeignKeyConstraint(['project_id'], ['projects.id'],
|
sa.Column('branch_id', sa.Integer(), nullable=True),
|
||||||
name='tasks_ibfk_3'),
|
sa.Column('milestone_id', sa.Integer(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['story_id'], ['stories.id'],
|
sa.ForeignKeyConstraint(['assignee_id'], ['users.id'],
|
||||||
name='tasks_ibfk_4'),
|
name='tasks_ibfk_1'),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.ForeignKeyConstraint(['project_id'], ['projects.id'],
|
||||||
mysql_engine=MYSQL_ENGINE,
|
name='tasks_ibfk_3'),
|
||||||
mysql_charset=MYSQL_CHARSET
|
sa.ForeignKeyConstraint(['story_id'], ['stories.id'],
|
||||||
)
|
name='tasks_ibfk_4'),
|
||||||
op.create_table(
|
sa.PrimaryKeyConstraint('id'),
|
||||||
'events',
|
mysql_engine=MYSQL_ENGINE,
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
mysql_charset=MYSQL_CHARSET
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
)
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
op.create_table(
|
||||||
sa.Column('story_id', sa.Integer(), nullable=True),
|
'events',
|
||||||
sa.Column('comment_id', sa.Integer(), nullable=True),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('author_id', sa.Integer(), nullable=True),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('event_type', sa.Unicode(length=100), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('event_info', sa.UnicodeText(), nullable=True),
|
sa.Column('story_id', sa.Integer(), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('comment_id', sa.Integer(), nullable=True),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.Column('author_id', sa.Integer(), nullable=True),
|
||||||
mysql_charset=MYSQL_CHARSET
|
sa.Column('event_type', sa.Unicode(length=100), nullable=False),
|
||||||
)
|
sa.Column('event_info', sa.UnicodeText(), nullable=True),
|
||||||
op.create_table(
|
sa.PrimaryKeyConstraint('id'),
|
||||||
'comments',
|
mysql_engine=MYSQL_ENGINE,
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
mysql_charset=MYSQL_CHARSET
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
)
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
op.create_table(
|
||||||
sa.Column('content', type_=MYSQL_MEDIUM_TEXT, nullable=True),
|
'comments',
|
||||||
sa.Column('is_active', sa.Boolean(), default=True,
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
server_default='1', nullable=False),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.Column('content', type_=MYSQL_MEDIUM_TEXT, nullable=True),
|
||||||
mysql_charset=MYSQL_CHARSET
|
sa.Column('is_active', sa.Boolean(), default=True,
|
||||||
)
|
server_default='1', nullable=False),
|
||||||
op.create_table(
|
sa.PrimaryKeyConstraint('id'),
|
||||||
'storytags',
|
mysql_engine=MYSQL_ENGINE,
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
mysql_charset=MYSQL_CHARSET
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
)
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
op.create_table(
|
||||||
sa.Column('name', sa.String(length=50), nullable=True),
|
'storytags',
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.UniqueConstraint('name', name='uniq_story_tags_name'),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
mysql_charset=MYSQL_CHARSET
|
sa.Column('name', sa.String(length=50), nullable=True),
|
||||||
)
|
sa.PrimaryKeyConstraint('id'),
|
||||||
op.create_table('story_storytags',
|
sa.UniqueConstraint('name', name='uniq_story_tags_name'),
|
||||||
sa.Column('story_id', sa.Integer(), nullable=True),
|
mysql_engine=MYSQL_ENGINE,
|
||||||
sa.Column('storytag_id', sa.Integer(), nullable=True),
|
mysql_charset=MYSQL_CHARSET
|
||||||
mysql_engine=MYSQL_ENGINE,
|
)
|
||||||
mysql_charset=MYSQL_CHARSET
|
op.create_table(
|
||||||
)
|
'story_storytags',
|
||||||
op.create_table(
|
sa.Column('story_id', sa.Integer(), nullable=True),
|
||||||
'subscriptions',
|
sa.Column('storytag_id', sa.Integer(), nullable=True),
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
mysql_engine=MYSQL_ENGINE,
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
mysql_charset=MYSQL_CHARSET
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
)
|
||||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
op.create_table(
|
||||||
sa.Column('target_type', enums['target_type'], nullable=True),
|
'subscriptions',
|
||||||
sa.Column('target_id', sa.Integer(), nullable=True),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
mysql_charset=MYSQL_CHARSET
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||||
)
|
sa.Column('target_type', enums['target_type'], nullable=True),
|
||||||
op.create_table(
|
sa.Column('target_id', sa.Integer(), nullable=True),
|
||||||
'subscription_events',
|
sa.PrimaryKeyConstraint('id'),
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
mysql_engine=MYSQL_ENGINE,
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
mysql_charset=MYSQL_CHARSET
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
)
|
||||||
sa.Column('subscriber_id', sa.Integer(), nullable=False),
|
op.create_table(
|
||||||
sa.Column('event_type', sa.Unicode(100), nullable=False),
|
'subscription_events',
|
||||||
sa.Column('event_info', sa.UnicodeText(), nullable=True),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('author_id', sa.Integer()),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.Column('subscriber_id', sa.Integer(), nullable=False),
|
||||||
mysql_charset=MYSQL_CHARSET
|
sa.Column('event_type', sa.Unicode(100), nullable=False),
|
||||||
)
|
sa.Column('event_info', sa.UnicodeText(), nullable=True),
|
||||||
op.create_table(
|
sa.Column('author_id', sa.Integer()),
|
||||||
'authorizationcodes',
|
sa.PrimaryKeyConstraint('id'),
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
mysql_engine=MYSQL_ENGINE,
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
mysql_charset=MYSQL_CHARSET
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
)
|
||||||
sa.Column('code', sa.Unicode(100), nullable=False),
|
op.create_table(
|
||||||
sa.Column('state', sa.Unicode(100), nullable=False),
|
'authorizationcodes',
|
||||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('expires_in', sa.Integer(), nullable=False),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('code', sa.Unicode(100), nullable=False),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.Column('state', sa.Unicode(100), nullable=False),
|
||||||
mysql_charset=MYSQL_CHARSET
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||||
)
|
sa.Column('expires_in', sa.Integer(), nullable=False),
|
||||||
op.create_table(
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||||
'accesstokens',
|
sa.PrimaryKeyConstraint('id'),
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
mysql_engine=MYSQL_ENGINE,
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
mysql_charset=MYSQL_CHARSET
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
)
|
||||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
op.create_table(
|
||||||
sa.Column('access_token', sa.Unicode(length=100), nullable=False),
|
'accesstokens',
|
||||||
sa.Column('expires_in', sa.Integer(), nullable=False),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('expires_at', sa.DateTime(), nullable=False),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||||
mysql_default_charset=MYSQL_CHARSET,
|
sa.Column('access_token', sa.Unicode(length=100), nullable=False),
|
||||||
mysql_engine=MYSQL_ENGINE
|
sa.Column('expires_in', sa.Integer(), nullable=False),
|
||||||
)
|
sa.Column('expires_at', sa.DateTime(), nullable=False),
|
||||||
op.create_table(
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||||
'refreshtokens',
|
sa.PrimaryKeyConstraint('id'),
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
mysql_default_charset=MYSQL_CHARSET,
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
mysql_engine=MYSQL_ENGINE
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
)
|
||||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
op.create_table(
|
||||||
sa.Column('refresh_token', sa.Unicode(length=100), nullable=False),
|
'refreshtokens',
|
||||||
sa.Column('expires_at', sa.DateTime(), nullable=False),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('expires_in', sa.Integer(), nullable=False),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('access_token_id', sa.Integer(), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('refresh_token', sa.Unicode(length=100), nullable=False),
|
||||||
mysql_default_charset=MYSQL_CHARSET,
|
sa.Column('expires_at', sa.DateTime(), nullable=False),
|
||||||
mysql_engine=MYSQL_ENGINE
|
sa.Column('expires_in', sa.Integer(), nullable=False),
|
||||||
)
|
sa.Column('access_token_id', sa.Integer(), nullable=False),
|
||||||
op.create_table(
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||||
'branches',
|
sa.PrimaryKeyConstraint('id'),
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
mysql_default_charset=MYSQL_CHARSET,
|
||||||
sa.Column('name', sa.String(100), nullable=True),
|
mysql_engine=MYSQL_ENGINE
|
||||||
sa.Column('project_id', sa.Integer(), nullable=True),
|
)
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
op.create_table(
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
'branches',
|
||||||
sa.Column('expired', sa.Boolean(), default=False, nullable=True),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('expiration_date', sa.DateTime(), default=None,
|
sa.Column('name', sa.String(100), nullable=True),
|
||||||
nullable=True),
|
sa.Column('project_id', sa.Integer(), nullable=True),
|
||||||
sa.Column('autocreated', sa.Boolean(), default=False, nullable=True),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('restricted', sa.Boolean(), default=False),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('expired', sa.Boolean(), default=False, nullable=True),
|
||||||
sa.UniqueConstraint('name', 'project_id', name="branch_un_constr"),
|
sa.Column('expiration_date', sa.DateTime(), default=None,
|
||||||
mysql_engine=MYSQL_ENGINE,
|
nullable=True),
|
||||||
mysql_charset=MYSQL_CHARSET
|
sa.Column('autocreated', sa.Boolean(), default=False,
|
||||||
)
|
nullable=True),
|
||||||
op.create_table(
|
sa.Column('restricted', sa.Boolean(), default=False),
|
||||||
'milestones',
|
sa.PrimaryKeyConstraint('id'),
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.UniqueConstraint('name', 'project_id', name="branch_un_constr"),
|
||||||
sa.Column('name', sa.String(100), nullable=True),
|
mysql_engine=MYSQL_ENGINE,
|
||||||
sa.Column('branch_id', sa.Integer(), nullable=True),
|
mysql_charset=MYSQL_CHARSET
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
)
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
op.create_table(
|
||||||
sa.Column('expired', sa.Boolean(), default=False, nullable=True),
|
'milestones',
|
||||||
sa.Column('expiration_date', sa.DateTime(), default=None),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('name', sa.String(100), nullable=True),
|
||||||
sa.UniqueConstraint('name', 'branch_id', name="milestone_un_constr"),
|
sa.Column('branch_id', sa.Integer(), nullable=True),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
mysql_charset=MYSQL_CHARSET
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
)
|
sa.Column('expired', sa.Boolean(), default=False, nullable=True),
|
||||||
op.create_table(
|
sa.Column('expiration_date', sa.DateTime(), default=None),
|
||||||
'story_types',
|
sa.PrimaryKeyConstraint('id'),
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.UniqueConstraint('name', 'branch_id',
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
name="milestone_un_constr"),
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
mysql_engine=MYSQL_ENGINE,
|
||||||
sa.Column('name', sa.String(50), nullable=True),
|
mysql_charset=MYSQL_CHARSET
|
||||||
sa.Column('icon', sa.String(50), nullable=True),
|
)
|
||||||
sa.Column('restricted', sa.Boolean(), default=False),
|
op.create_table(
|
||||||
sa.Column('private', sa.Boolean(), default=False),
|
'story_types',
|
||||||
sa.Column('visible', sa.Boolean(), default=True),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
mysql_engine=MYSQL_ENGINE,
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
mysql_charset=MYSQL_CHARSET
|
sa.Column('name', sa.String(50), nullable=True),
|
||||||
)
|
sa.Column('icon', sa.String(50), nullable=True),
|
||||||
op.create_table(
|
sa.Column('restricted', sa.Boolean(), default=False),
|
||||||
'may_mutate_to',
|
sa.Column('private', sa.Boolean(), default=False),
|
||||||
sa.Column('story_type_id_from', sa.Integer(), nullable=False),
|
sa.Column('visible', sa.Boolean(), default=True),
|
||||||
sa.Column('story_type_id_to', sa.Integer(), nullable=False),
|
sa.PrimaryKeyConstraint('id'),
|
||||||
sa.UniqueConstraint('story_type_id_from',
|
mysql_engine=MYSQL_ENGINE,
|
||||||
'story_type_id_to',
|
mysql_charset=MYSQL_CHARSET
|
||||||
name="mutate_un_constr"),
|
)
|
||||||
sa.PrimaryKeyConstraint(),
|
op.create_table(
|
||||||
mysql_engine=MYSQL_ENGINE,
|
'may_mutate_to',
|
||||||
mysql_charset=MYSQL_CHARSET
|
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
|
# Create story types
|
||||||
bind = op.get_bind()
|
bind = op.get_bind()
|
||||||
@ -454,34 +462,37 @@ def upgrade(active_plugins=None, options=None):
|
|||||||
story_type_id_to=1
|
story_type_id_to=1
|
||||||
))
|
))
|
||||||
|
|
||||||
op.create_index('accesstokens_access_token_idx',
|
if dialect.supports_alter:
|
||||||
'accesstokens', ['access_token'])
|
op.create_index('accesstokens_access_token_idx',
|
||||||
|
'accesstokens', ['access_token'])
|
||||||
|
|
||||||
version_info = op.get_bind().engine.dialect.server_version_info
|
version_info = op.get_bind().engine.dialect.server_version_info
|
||||||
if version_info[-1] == "MariaDB":
|
if version_info[-1] == "MariaDB":
|
||||||
# Removes fake mysql prefix
|
# Removes fake mysql prefix
|
||||||
version_info = version_info[-4:]
|
version_info = version_info[-4:]
|
||||||
if version_info[0] < 5 or version_info[0] == 5 and version_info[1] < 6:
|
if version_info[0] < 5 or version_info[0] == 5 and version_info[1] < 6:
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"MySQL version is lower than 5.6. Skipping full-text indexes")
|
"MySQL version is lower than 5.6. Skipping full-text indexes")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Index for projects
|
# Index for projects
|
||||||
op.execute("ALTER TABLE projects "
|
op.execute("ALTER TABLE projects "
|
||||||
"ADD FULLTEXT projects_fti (name, description)")
|
"ADD FULLTEXT projects_fti (name, description)")
|
||||||
|
|
||||||
# Index for stories
|
# Index for stories
|
||||||
op.execute("ALTER TABLE stories "
|
op.execute("ALTER TABLE stories "
|
||||||
"ADD FULLTEXT stories_fti (title, description)")
|
"ADD FULLTEXT stories_fti (title, description)")
|
||||||
|
|
||||||
# Index for tasks
|
# Index for tasks
|
||||||
op.execute("ALTER TABLE tasks ADD FULLTEXT tasks_fti (title)")
|
op.execute("ALTER TABLE tasks ADD FULLTEXT tasks_fti (title)")
|
||||||
|
|
||||||
# Index for comments
|
# Index for comments
|
||||||
op.execute("ALTER TABLE comments ADD FULLTEXT comments_fti (content)")
|
op.execute("ALTER TABLE comments ADD FULLTEXT comments_fti (content)")
|
||||||
|
|
||||||
# Index for users
|
# Index for users
|
||||||
op.execute("ALTER TABLE users ADD FULLTEXT users_fti (full_name, email)")
|
op.execute(
|
||||||
|
"ALTER TABLE users ADD FULLTEXT users_fti (full_name, email)"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def downgrade(active_plugins=None, options=None):
|
def downgrade(active_plugins=None, options=None):
|
||||||
|
@ -28,9 +28,12 @@ from alembic import op
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
import storyboard
|
import storyboard
|
||||||
|
from storyboard.db.migration import utils
|
||||||
|
|
||||||
|
|
||||||
|
@utils.not_sqlite
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
|
|
||||||
op.create_table('worklists',
|
op.create_table('worklists',
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('created_at',
|
sa.Column('created_at',
|
||||||
|
@ -31,9 +31,11 @@ from sqlalchemy.dialects import mysql
|
|||||||
from storyboard.db.api import base as api_base
|
from storyboard.db.api import base as api_base
|
||||||
from storyboard.db.api import boards
|
from storyboard.db.api import boards
|
||||||
from storyboard.db.api import worklists
|
from storyboard.db.api import worklists
|
||||||
|
from storyboard.db.migration import utils
|
||||||
from storyboard.db import models
|
from storyboard.db import models
|
||||||
|
|
||||||
|
|
||||||
|
@utils.not_sqlite
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
op.create_table('board_permissions',
|
op.create_table('board_permissions',
|
||||||
sa.Column('board_id', sa.Integer(), nullable=True),
|
sa.Column('board_id', sa.Integer(), nullable=True),
|
||||||
|
@ -27,7 +27,10 @@ down_revision = '051'
|
|||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
from storyboard.db.migration import utils
|
||||||
|
|
||||||
|
|
||||||
|
@utils.not_sqlite
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
|
|
||||||
op.add_column('tasks', sa.Column('link', sa.UnicodeText(), nullable=True))
|
op.add_column('tasks', sa.Column('link', sa.UnicodeText(), nullable=True))
|
||||||
|
@ -28,8 +28,10 @@ from alembic import op
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
from storyboard.db.decorators import UTCDateTime
|
from storyboard.db.decorators import UTCDateTime
|
||||||
|
from storyboard.db.migration import utils
|
||||||
|
|
||||||
|
|
||||||
|
@utils.not_sqlite
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'due_dates',
|
'due_dates',
|
||||||
|
@ -27,7 +27,10 @@ down_revision = '053'
|
|||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
from storyboard.db.migration import utils
|
||||||
|
|
||||||
|
|
||||||
|
@utils.not_sqlite
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
op.add_column(
|
op.add_column(
|
||||||
'worklist_items', sa.Column('archived', sa.Boolean(), nullable=True))
|
'worklist_items', sa.Column('archived', sa.Boolean(), nullable=True))
|
||||||
|
@ -27,7 +27,10 @@ down_revision = '054'
|
|||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
from storyboard.db.migration import utils
|
||||||
|
|
||||||
|
|
||||||
|
@utils.not_sqlite
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
op.add_column(
|
op.add_column(
|
||||||
'comments', sa.Column('in_reply_to', sa.Integer(), nullable=True))
|
'comments', sa.Column('in_reply_to', sa.Integer(), nullable=True))
|
||||||
|
@ -29,8 +29,10 @@ import sqlalchemy as sa
|
|||||||
from sqlalchemy.dialects import mysql
|
from sqlalchemy.dialects import mysql
|
||||||
|
|
||||||
import storyboard
|
import storyboard
|
||||||
|
from storyboard.db.migration import utils
|
||||||
|
|
||||||
|
|
||||||
|
@utils.not_sqlite
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'worklist_filters',
|
'worklist_filters',
|
||||||
|
@ -37,7 +37,10 @@ from alembic import op
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy.dialects import mysql
|
from sqlalchemy.dialects import mysql
|
||||||
|
|
||||||
|
from storyboard.db.migration import utils
|
||||||
|
|
||||||
|
|
||||||
|
@utils.not_sqlite
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'story_permissions',
|
'story_permissions',
|
||||||
|
@ -27,11 +27,14 @@ down_revision = '057'
|
|||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
from storyboard.db.migration import utils
|
||||||
|
|
||||||
old_type_enum = sa.Enum('task', 'story', 'project', 'project_group')
|
old_type_enum = sa.Enum('task', 'story', 'project', 'project_group')
|
||||||
new_type_enum = sa.Enum(
|
new_type_enum = sa.Enum(
|
||||||
'task', 'story', 'project', 'project_group', 'worklist')
|
'task', 'story', 'project', 'project_group', 'worklist')
|
||||||
|
|
||||||
|
|
||||||
|
@utils.not_sqlite
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
dialect = op.get_bind().engine.dialect
|
dialect = op.get_bind().engine.dialect
|
||||||
if dialect.supports_alter:
|
if dialect.supports_alter:
|
||||||
|
@ -28,9 +28,11 @@ from alembic import op
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
from storyboard.db.decorators import UTCDateTime
|
from storyboard.db.decorators import UTCDateTime
|
||||||
|
from storyboard.db.migration import utils
|
||||||
from storyboard.db.models import MYSQL_MEDIUM_TEXT
|
from storyboard.db.models import MYSQL_MEDIUM_TEXT
|
||||||
|
|
||||||
|
|
||||||
|
@utils.not_sqlite
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'comments_history',
|
'comments_history',
|
||||||
|
@ -27,7 +27,10 @@ down_revision = '059'
|
|||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
from storyboard.db.migration import utils
|
||||||
|
|
||||||
|
|
||||||
|
@utils.not_sqlite
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
op.add_column(
|
op.add_column(
|
||||||
'events', sa.Column('board_id', sa.Integer(), nullable=True))
|
'events', sa.Column('board_id', sa.Integer(), nullable=True))
|
||||||
|
@ -27,7 +27,10 @@ down_revision = '060'
|
|||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
from storyboard.db.migration import utils
|
||||||
|
|
||||||
|
|
||||||
|
@utils.not_sqlite
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
dialect = op.get_bind().engine.dialect
|
dialect = op.get_bind().engine.dialect
|
||||||
if dialect.supports_alter:
|
if dialect.supports_alter:
|
||||||
|
@ -26,7 +26,10 @@ down_revision = '062'
|
|||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
from storyboard.db.migration import utils
|
||||||
|
|
||||||
|
|
||||||
|
@utils.not_sqlite
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
op.create_index('story_storytags_idx',
|
op.create_index('story_storytags_idx',
|
||||||
'story_storytags', ['story_id'])
|
'story_storytags', ['story_id'])
|
||||||
|
27
storyboard/db/migration/utils.py
Normal file
27
storyboard/db/migration/utils.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
import functools
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
|
def not_sqlite(f):
|
||||||
|
"Decorator to skip migrations for sqlite databases."
|
||||||
|
@functools.wraps(f)
|
||||||
|
def upgrade(active_plugins=None, options=None):
|
||||||
|
dialect = op.get_bind().engine.dialect
|
||||||
|
if dialect.name == 'sqlite':
|
||||||
|
return
|
||||||
|
return f(active_plugins, options)
|
||||||
|
return upgrade
|
@ -63,6 +63,30 @@ def table_args():
|
|||||||
MYSQL_MEDIUM_TEXT = UnicodeText().with_variant(MEDIUMTEXT(), 'mysql')
|
MYSQL_MEDIUM_TEXT = UnicodeText().with_variant(MEDIUMTEXT(), 'mysql')
|
||||||
|
|
||||||
|
|
||||||
|
class ManagedFullText(FullText):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def build_fulltext(cls, table):
|
||||||
|
"""Override FullText to avoid adding DDL instructions.
|
||||||
|
|
||||||
|
This mix-in replaces sqlalchemy_fulltext.FullText and does not
|
||||||
|
automatically cause the database engine to create the full text
|
||||||
|
search index columns. We do that using our alembic migration
|
||||||
|
scripts, instead.
|
||||||
|
|
||||||
|
We need this class to support running the unit tests under sqlite,
|
||||||
|
which doesn't support the full text indexing features of MySQL,
|
||||||
|
since sqlalchemy-fulltext-search always runs the DDL, even if the
|
||||||
|
database dialect is not 'mysql'.
|
||||||
|
|
||||||
|
After the change in
|
||||||
|
https://github.com/mengzhuo/sqlalchemy-fulltext-search/pull/15
|
||||||
|
is approved and released we can remove this class.
|
||||||
|
|
||||||
|
"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class CommonLength(object):
|
class CommonLength(object):
|
||||||
top_large_length = 255
|
top_large_length = 255
|
||||||
top_middle_length = 100
|
top_middle_length = 100
|
||||||
@ -137,7 +161,7 @@ team_membership = Table(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class User(FullText, ModelBuilder, Base):
|
class User(ManagedFullText, ModelBuilder, Base):
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
schema.UniqueConstraint('email', name='uniq_user_email'),
|
schema.UniqueConstraint('email', name='uniq_user_email'),
|
||||||
)
|
)
|
||||||
@ -255,7 +279,7 @@ class Permission(ModelBuilder, Base):
|
|||||||
|
|
||||||
|
|
||||||
# TODO(mordred): Do we really need name and title?
|
# TODO(mordred): Do we really need name and title?
|
||||||
class Project(FullText, ModelBuilder, Base):
|
class Project(ManagedFullText, ModelBuilder, Base):
|
||||||
"""Represents a software project."""
|
"""Represents a software project."""
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
@ -300,7 +324,7 @@ story_storytags = Table(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Story(FullText, ModelBuilder, Base):
|
class Story(ManagedFullText, ModelBuilder, Base):
|
||||||
__tablename__ = 'stories'
|
__tablename__ = 'stories'
|
||||||
|
|
||||||
__fulltext_columns__ = ['title', 'description']
|
__fulltext_columns__ = ['title', 'description']
|
||||||
@ -324,7 +348,7 @@ class Story(FullText, ModelBuilder, Base):
|
|||||||
"tasks", "events", "tags"]
|
"tasks", "events", "tags"]
|
||||||
|
|
||||||
|
|
||||||
class Task(FullText, ModelBuilder, Base):
|
class Task(ManagedFullText, ModelBuilder, Base):
|
||||||
__fulltext_columns__ = ['title']
|
__fulltext_columns__ = ['title']
|
||||||
|
|
||||||
TASK_STATUSES = {'todo': 'Todo',
|
TASK_STATUSES = {'todo': 'Todo',
|
||||||
@ -504,7 +528,7 @@ class TimeLineEvent(ModelBuilder, Base):
|
|||||||
event_info = Column(UnicodeText(), nullable=True)
|
event_info = Column(UnicodeText(), nullable=True)
|
||||||
|
|
||||||
|
|
||||||
class Comment(FullText, ModelBuilder, Base):
|
class Comment(ManagedFullText, ModelBuilder, Base):
|
||||||
__fulltext_columns__ = ['content']
|
__fulltext_columns__ = ['content']
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
@ -514,7 +538,7 @@ class Comment(FullText, ModelBuilder, Base):
|
|||||||
parent = relationship('Comment', remote_side=[id], backref='children')
|
parent = relationship('Comment', remote_side=[id], backref='children')
|
||||||
|
|
||||||
|
|
||||||
class HistoricalComment(FullText, ModelBuilder, Base):
|
class HistoricalComment(ManagedFullText, ModelBuilder, Base):
|
||||||
__tablename__ = 'comments_history'
|
__tablename__ = 'comments_history'
|
||||||
__fulltext_columns__ = ['content']
|
__fulltext_columns__ = ['content']
|
||||||
|
|
||||||
@ -569,7 +593,7 @@ class WorklistItem(ModelBuilder, Base):
|
|||||||
"item_id"]
|
"item_id"]
|
||||||
|
|
||||||
|
|
||||||
class FilterCriterion(FullText, ModelBuilder, Base):
|
class FilterCriterion(ManagedFullText, ModelBuilder, Base):
|
||||||
__tablename__ = "filter_criteria"
|
__tablename__ = "filter_criteria"
|
||||||
__fulltext_columns__ = ['title']
|
__fulltext_columns__ = ['title']
|
||||||
|
|
||||||
@ -594,7 +618,7 @@ class WorklistFilter(ModelBuilder, Base):
|
|||||||
_public_fields = ["id", "list_id", "type"]
|
_public_fields = ["id", "list_id", "type"]
|
||||||
|
|
||||||
|
|
||||||
class Worklist(FullText, ModelBuilder, Base):
|
class Worklist(ManagedFullText, ModelBuilder, Base):
|
||||||
__tablename__ = "worklists"
|
__tablename__ = "worklists"
|
||||||
__fulltext_columns__ = ['title']
|
__fulltext_columns__ = ['title']
|
||||||
|
|
||||||
@ -622,7 +646,7 @@ class BoardWorklist(ModelBuilder, Base):
|
|||||||
_public_fields = ["id", "board_id", "list_id", "position"]
|
_public_fields = ["id", "board_id", "list_id", "position"]
|
||||||
|
|
||||||
|
|
||||||
class Board(FullText, ModelBuilder, Base):
|
class Board(ManagedFullText, ModelBuilder, Base):
|
||||||
__tablename__ = "boards"
|
__tablename__ = "boards"
|
||||||
__fulltext_columns__ = ['title', 'description']
|
__fulltext_columns__ = ['title', 'description']
|
||||||
|
|
||||||
@ -651,7 +675,7 @@ worklist_permissions = Table(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class DueDate(FullText, ModelBuilder, Base):
|
class DueDate(ManagedFullText, ModelBuilder, Base):
|
||||||
__tablename__ = "due_dates"
|
__tablename__ = "due_dates"
|
||||||
__fulltext_columns__ = ['name']
|
__fulltext_columns__ = ['name']
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import shutil
|
import shutil
|
||||||
|
import sqlite3
|
||||||
import stat
|
import stat
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@ -35,6 +36,7 @@ import testtools
|
|||||||
import storyboard.common.working_dir as working_dir
|
import storyboard.common.working_dir as working_dir
|
||||||
from storyboard.db.api import base as db_api_base
|
from storyboard.db.api import base as db_api_base
|
||||||
from storyboard.db.migration.cli import get_alembic_config
|
from storyboard.db.migration.cli import get_alembic_config
|
||||||
|
from storyboard.db import models
|
||||||
import storyboard.tests.mock_data as mock_data
|
import storyboard.tests.mock_data as mock_data
|
||||||
|
|
||||||
|
|
||||||
@ -152,9 +154,19 @@ class DbTestCase(WorkingDirTestCase):
|
|||||||
CONF.set_override("connection", dburi, group="database")
|
CONF.set_override("connection", dburi, group="database")
|
||||||
self._full_db_name = self.test_connection + '/' + self.db_name
|
self._full_db_name = self.test_connection + '/' + self.db_name
|
||||||
LOG.info('using database %s', CONF.database.connection)
|
LOG.info('using database %s', CONF.database.connection)
|
||||||
|
LOG.info('test_connection %r', self.test_connection)
|
||||||
|
|
||||||
if self.test_connection.startswith('sqlite://'):
|
if self.test_connection.startswith('sqlite://'):
|
||||||
self.using_sqlite = True
|
self.using_sqlite = True
|
||||||
|
filename = self._full_db_name[9:]
|
||||||
|
if filename[:2] == '//':
|
||||||
|
filename = filename[1:]
|
||||||
|
if not os.path.exists(filename):
|
||||||
|
# NOTE(dhellmann): Connect and disconnect to create
|
||||||
|
# the empty database file.
|
||||||
|
sqlite3.connect(filename).close()
|
||||||
|
engine = sqlalchemy.create_engine(self._full_db_name)
|
||||||
|
models.Base.metadata.create_all(engine)
|
||||||
else:
|
else:
|
||||||
self.using_sqlite = False
|
self.using_sqlite = False
|
||||||
# The engine w/o db name
|
# The engine w/o db name
|
||||||
|
Loading…
Reference in New Issue
Block a user