From a065a2c873e80ea933b5cb6ef542ad7a759714e1 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Wed, 3 Feb 2016 19:23:39 +0100 Subject: carpy tests for alembic... --- migrations/README | 1 + migrations/alembic.ini | 68 +++++++++++++++++++++ migrations/env.py | 70 ++++++++++++++++++++++ migrations/script.py.mako | 24 ++++++++ ...b75f3fe_changed_the_type_of_the_column_last_.py | 34 +++++++++++ migrations/versions/19bdaa6208e_add_icon_column.py | 26 ++++++++ ...b750a389c22_remove_email_notification_column.py | 25 ++++++++ ...ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py | 36 +++++++++++ .../versions/422da2d0234_adding_filters_field.py | 22 +++++++ .../versions/48f561c0ce6_add_column_entry_id.py | 26 ++++++++ ...34831ea_adding_feed_and_user_attributes_for_.py | 44 ++++++++++++++ src/alembic.ini | 68 +++++++++++++++++++++ src/migrations/README | 1 - src/migrations/alembic.ini | 45 -------------- src/migrations/env.py | 70 ---------------------- src/migrations/script.py.mako | 22 ------- ...b75f3fe_changed_the_type_of_the_column_last_.py | 34 ----------- .../versions/19bdaa6208e_add_icon_column.py | 26 -------- ...b750a389c22_remove_email_notification_column.py | 25 -------- ...ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py | 36 ----------- .../versions/3f83bfe93fc_adding_category.py | 42 ------------- .../versions/422da2d0234_adding_filters_field.py | 22 ------- .../versions/48f561c0ce6_add_column_entry_id.py | 26 -------- ...34831ea_adding_feed_and_user_attributes_for_.py | 44 -------------- .../db64b766362f_add_notes_column_for_articles.py | 22 ------- src/migrations1/README | 1 + src/migrations1/env.py | 70 ++++++++++++++++++++++ src/migrations1/script.py.mako | 24 ++++++++ 28 files changed, 539 insertions(+), 415 deletions(-) create mode 100644 migrations/README create mode 100644 migrations/alembic.ini create mode 100644 migrations/env.py create mode 100644 migrations/script.py.mako create mode 100644 migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py create mode 100644 migrations/versions/19bdaa6208e_add_icon_column.py create mode 100644 migrations/versions/1b750a389c22_remove_email_notification_column.py create mode 100644 migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py create mode 100644 migrations/versions/422da2d0234_adding_filters_field.py create mode 100644 migrations/versions/48f561c0ce6_add_column_entry_id.py create mode 100644 migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py create mode 100644 src/alembic.ini delete mode 100755 src/migrations/README delete mode 100644 src/migrations/alembic.ini delete mode 100644 src/migrations/env.py delete mode 100755 src/migrations/script.py.mako delete mode 100644 src/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py delete mode 100644 src/migrations/versions/19bdaa6208e_add_icon_column.py delete mode 100644 src/migrations/versions/1b750a389c22_remove_email_notification_column.py delete mode 100644 src/migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py delete mode 100644 src/migrations/versions/3f83bfe93fc_adding_category.py delete mode 100644 src/migrations/versions/422da2d0234_adding_filters_field.py delete mode 100644 src/migrations/versions/48f561c0ce6_add_column_entry_id.py delete mode 100644 src/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py delete mode 100644 src/migrations/versions/db64b766362f_add_notes_column_for_articles.py create mode 100644 src/migrations1/README create mode 100644 src/migrations1/env.py create mode 100644 src/migrations1/script.py.mako diff --git a/migrations/README b/migrations/README new file mode 100644 index 00000000..98e4f9c4 --- /dev/null +++ b/migrations/README @@ -0,0 +1 @@ +Generic single-database configuration. \ No newline at end of file diff --git a/migrations/alembic.ini b/migrations/alembic.ini new file mode 100644 index 00000000..1c105dc6 --- /dev/null +++ b/migrations/alembic.ini @@ -0,0 +1,68 @@ +# A generic, single database configuration. + +[alembic] +# path to migration scripts +script_location = migrations1/ + +# template used to generate migration files +# file_template = %%(rev)s_%%(slug)s + +# max length of characters to apply to the +# "slug" field +#truncate_slug_length = 40 + +# set to 'true' to run the environment during +# the 'revision' command, regardless of autogenerate +# revision_environment = false + +# set to 'true' to allow .pyc and .pyo files without +# a source .py file to be detected as revisions in the +# versions/ directory +# sourceless = false + +# version location specification; this defaults +# to migrations1//versions. When using multiple version +# directories, initial revisions must be specified with --version-path +# version_locations = %(here)s/bar %(here)s/bat migrations1//versions + +# the output encoding used when revision files +# are written from script.py.mako +# output_encoding = utf-8 + +sqlalchemy.url = driver://user:pass@localhost/dbname + + +# Logging configuration +[loggers] +keys = root,sqlalchemy,alembic + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console +qualname = + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine + +[logger_alembic] +level = INFO +handlers = +qualname = alembic + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(levelname)-5.5s [%(name)s] %(message)s +datefmt = %H:%M:%S diff --git a/migrations/env.py b/migrations/env.py new file mode 100644 index 00000000..7215fefe --- /dev/null +++ b/migrations/env.py @@ -0,0 +1,70 @@ +from __future__ import with_statement +from alembic import context +from sqlalchemy import engine_from_config, pool +from logging.config import fileConfig + +# this is the Alembic Config object, which provides +# access to the values within the .ini file in use. +config = context.config + +# Interpret the config file for Python logging. +# This line sets up loggers basically. +#fileConfig("./alembic.ini") + +# add your model's MetaData object here +# for 'autogenerate' support +# from myapp import mymodel +# target_metadata = mymodel.Base.metadata +from flask import current_app +config.set_main_option('sqlalchemy.url', current_app.config.get('SQLALCHEMY_DATABASE_URI')) +target_metadata = current_app.extensions['migrate'].db.metadata + + +# other values from the config, defined by the needs of env.py, +# can be acquired: +# my_important_option = config.get_main_option("my_important_option") +# ... etc. + +def run_migrations_offline(): + """Run migrations in 'offline' mode. + + This configures the context with just a URL + and not an Engine, though an Engine is acceptable + here as well. By skipping the Engine creation + we don't even need a DBAPI to be available. + + Calls to context.execute() here emit the given string to the + script output. + + """ + url = config.get_main_option("sqlalchemy.url") + context.configure(url=url) + + with context.begin_transaction(): + context.run_migrations() + +def run_migrations_online(): + """Run migrations in 'online' mode. + + In this scenario we need to create an Engine + and associate a connection with the context. + + """ + connectable = engine_from_config( + config.get_section(config.config_ini_section), + prefix='sqlalchemy.', + poolclass=pool.NullPool) + + with connectable.connect() as connection: + context.configure( + connection=connection, + target_metadata=target_metadata + ) + + with context.begin_transaction(): + context.run_migrations() + +if context.is_offline_mode(): + run_migrations_offline() +else: + run_migrations_online() diff --git a/migrations/script.py.mako b/migrations/script.py.mako new file mode 100644 index 00000000..43c09401 --- /dev/null +++ b/migrations/script.py.mako @@ -0,0 +1,24 @@ +"""${message} + +Revision ID: ${up_revision} +Revises: ${down_revision | comma,n} +Create Date: ${create_date} + +""" + +# revision identifiers, used by Alembic. +revision = ${repr(up_revision)} +down_revision = ${repr(down_revision)} +branch_labels = ${repr(branch_labels)} +depends_on = ${repr(depends_on)} + +from alembic import op +import sqlalchemy as sa +${imports if imports else ""} + +def upgrade(): + ${upgrades if upgrades else "pass"} + + +def downgrade(): + ${downgrades if downgrades else "pass"} diff --git a/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py b/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py new file mode 100644 index 00000000..035646c6 --- /dev/null +++ b/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py @@ -0,0 +1,34 @@ +"""changed the type of the column 'last_modified' to string. + +Revision ID: 17dcb75f3fe +Revises: cde34831ea +Create Date: 2015-03-10 14:20:53.676344 + +""" + +# revision identifiers, used by Alembic. +revision = '17dcb75f3fe' +down_revision = 'cde34831ea' + +from datetime import datetime +import conf +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + unix_start = datetime(1970, 1, 1) + if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: + op.drop_column('feed', 'last_modified') + op.add_column('feed', sa.Column('last_modified', sa.String(), + nullable=True, default=unix_start, + server_default=str(unix_start))) + + +def downgrade(): + unix_start = datetime(1970, 1, 1) + if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: + op.drop_column('feed', 'last_modified') + op.add_column('feed', sa.Column('last_modified', sa.DateTime(), + nullable=True, default=unix_start, + server_default=unix_start)) diff --git a/migrations/versions/19bdaa6208e_add_icon_column.py b/migrations/versions/19bdaa6208e_add_icon_column.py new file mode 100644 index 00000000..2efa376f --- /dev/null +++ b/migrations/versions/19bdaa6208e_add_icon_column.py @@ -0,0 +1,26 @@ +"""adding icon columns + +Revision ID: 19bdaa6208e +Revises: 422da2d0234 +Create Date: 2015-07-03 12:09:58.596010 + +""" + +# revision identifiers, used by Alembic. +revision = '19bdaa6208e' +down_revision = '422da2d0234' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + ### commands auto generated by Alembic - please adjust! ### + op.add_column('feed', sa.Column('icon', sa.String(), nullable=True)) + ### end Alembic commands ### + + +def downgrade(): + ### commands auto generated by Alembic - please adjust! ### + op.drop_column('feed', 'icon') + ### end Alembic commands ### diff --git a/migrations/versions/1b750a389c22_remove_email_notification_column.py b/migrations/versions/1b750a389c22_remove_email_notification_column.py new file mode 100644 index 00000000..71529855 --- /dev/null +++ b/migrations/versions/1b750a389c22_remove_email_notification_column.py @@ -0,0 +1,25 @@ +"""remove email_notification column + +Revision ID: 1b750a389c22 +Revises: 48f561c0ce6 +Create Date: 2015-02-25 23:01:07.253429 + +""" + +# revision identifiers, used by Alembic. +revision = '1b750a389c22' +down_revision = '48f561c0ce6' + +import conf +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: + op.drop_column('feed', 'email_notification') + + +def downgrade(): + op.add_column('feed', sa.Column('email_notification', sa.Boolean(), + default=False)) diff --git a/migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py b/migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py new file mode 100644 index 00000000..2c8eeda5 --- /dev/null +++ b/migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py @@ -0,0 +1,36 @@ +"""moving icons to their own table + +Revision ID: 25ca960a207 +Revises: 19bdaa6208e +Create Date: 2015-08-03 14:36:21.626411 + +""" + +# revision identifiers, used by Alembic. +revision = '25ca960a207' +down_revision = '19bdaa6208e' + +from alembic import op +import sqlalchemy as sa + +import conf + + +def upgrade(): + op.create_table('icon', + sa.Column('url', sa.String(), nullable=False), + sa.Column('content', sa.String(), nullable=True), + sa.Column('mimetype', sa.String(), nullable=True), + sa.PrimaryKeyConstraint('url')) + op.add_column('feed', sa.Column('icon_url', sa.String(), nullable=True)) + if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: + op.create_foreign_key(None, 'feed', 'icon', ['icon_url'], ['url']) + op.drop_column('feed', 'icon') + + +def downgrade(): + op.add_column('feed', sa.Column('icon', sa.VARCHAR(), nullable=True)) + if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: + op.drop_constraint(None, 'feed', type_='foreignkey') + op.drop_column('feed', 'icon_url') + op.drop_table('icon') diff --git a/migrations/versions/422da2d0234_adding_filters_field.py b/migrations/versions/422da2d0234_adding_filters_field.py new file mode 100644 index 00000000..bcbdf042 --- /dev/null +++ b/migrations/versions/422da2d0234_adding_filters_field.py @@ -0,0 +1,22 @@ +"""adding filters field + +Revision ID: 422da2d0234 +Revises: 17dcb75f3fe +Create Date: 2015-05-18 23:03:15.809549 + +""" + +# revision identifiers, used by Alembic. +revision = '422da2d0234' +down_revision = '17dcb75f3fe' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('feed', sa.Column('filters', sa.PickleType(), nullable=True)) + + +def downgrade(): + op.drop_column('feed', 'filters') diff --git a/migrations/versions/48f561c0ce6_add_column_entry_id.py b/migrations/versions/48f561c0ce6_add_column_entry_id.py new file mode 100644 index 00000000..f464849a --- /dev/null +++ b/migrations/versions/48f561c0ce6_add_column_entry_id.py @@ -0,0 +1,26 @@ +"""add column entry_id + +Revision ID: 48f561c0ce6 +Revises: +Create Date: 2015-02-18 21:17:19.346998 + +""" + +# revision identifiers, used by Alembic. +revision = '48f561c0ce6' +down_revision = None +branch_labels = None +depends_on = None + +import conf +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('article', sa.Column('entry_id', sa.String(), nullable=True)) + + +def downgrade(): + if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: + op.drop_column('article', 'entry_id') diff --git a/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py b/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py new file mode 100644 index 00000000..8763f925 --- /dev/null +++ b/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py @@ -0,0 +1,44 @@ +"""adding feed and user attributes for better feed retreiving + +Revision ID: cde34831ea +Revises: 1b750a389c22 +Create Date: 2015-03-04 22:59:44.665979 + +""" + +# revision identifiers, used by Alembic. +revision = 'cde34831ea' +down_revision = '1b750a389c22' +import conf +from datetime import datetime + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + unix_start = datetime(1970, 1, 1) + # commands auto generated by Alembic - please adjust! ### + op.add_column('feed', sa.Column('error_count', sa.Integer(), nullable=True, + default=0, server_default="0")) + op.add_column('feed', sa.Column('last_error', sa.String(), nullable=True)) + op.add_column('feed', sa.Column('last_modified', sa.DateTime(), + nullable=True, default=unix_start, server_default=str(unix_start))) + op.add_column('feed', sa.Column('last_retrieved', sa.DateTime(), + nullable=True, default=unix_start, server_default=str(unix_start))) + op.add_column('feed', sa.Column('etag', sa.String(), nullable=True)) + op.add_column('user', sa.Column('refresh_rate', sa.Integer(), + nullable=True, default=60)) + # end Alembic commands ### + + +def downgrade(): + # commands auto generated by Alembic - please adjust! ### + if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: + op.drop_column('user', 'refresh_rate') + op.drop_column('feed', 'last_modified') + op.drop_column('feed', 'last_error') + op.drop_column('feed', 'error_count') + op.drop_column('feed', 'last_retrieved') + op.drop_column('feed', 'etag') + # end Alembic commands ### diff --git a/src/alembic.ini b/src/alembic.ini new file mode 100644 index 00000000..1c105dc6 --- /dev/null +++ b/src/alembic.ini @@ -0,0 +1,68 @@ +# A generic, single database configuration. + +[alembic] +# path to migration scripts +script_location = migrations1/ + +# template used to generate migration files +# file_template = %%(rev)s_%%(slug)s + +# max length of characters to apply to the +# "slug" field +#truncate_slug_length = 40 + +# set to 'true' to run the environment during +# the 'revision' command, regardless of autogenerate +# revision_environment = false + +# set to 'true' to allow .pyc and .pyo files without +# a source .py file to be detected as revisions in the +# versions/ directory +# sourceless = false + +# version location specification; this defaults +# to migrations1//versions. When using multiple version +# directories, initial revisions must be specified with --version-path +# version_locations = %(here)s/bar %(here)s/bat migrations1//versions + +# the output encoding used when revision files +# are written from script.py.mako +# output_encoding = utf-8 + +sqlalchemy.url = driver://user:pass@localhost/dbname + + +# Logging configuration +[loggers] +keys = root,sqlalchemy,alembic + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console +qualname = + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine + +[logger_alembic] +level = INFO +handlers = +qualname = alembic + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(levelname)-5.5s [%(name)s] %(message)s +datefmt = %H:%M:%S diff --git a/src/migrations/README b/src/migrations/README deleted file mode 100755 index 98e4f9c4..00000000 --- a/src/migrations/README +++ /dev/null @@ -1 +0,0 @@ -Generic single-database configuration. \ No newline at end of file diff --git a/src/migrations/alembic.ini b/src/migrations/alembic.ini deleted file mode 100644 index f8ed4801..00000000 --- a/src/migrations/alembic.ini +++ /dev/null @@ -1,45 +0,0 @@ -# A generic, single database configuration. - -[alembic] -# template used to generate migration files -# file_template = %%(rev)s_%%(slug)s - -# set to 'true' to run the environment during -# the 'revision' command, regardless of autogenerate -# revision_environment = false - - -# Logging configuration -[loggers] -keys = root,sqlalchemy,alembic - -[handlers] -keys = console - -[formatters] -keys = generic - -[logger_root] -level = WARN -handlers = console -qualname = - -[logger_sqlalchemy] -level = WARN -handlers = -qualname = sqlalchemy.engine - -[logger_alembic] -level = INFO -handlers = -qualname = alembic - -[handler_console] -class = StreamHandler -args = (sys.stderr,) -level = NOTSET -formatter = generic - -[formatter_generic] -format = %(levelname)-5.5s [%(name)s] %(message)s -datefmt = %H:%M:%S diff --git a/src/migrations/env.py b/src/migrations/env.py deleted file mode 100644 index 7215fefe..00000000 --- a/src/migrations/env.py +++ /dev/null @@ -1,70 +0,0 @@ -from __future__ import with_statement -from alembic import context -from sqlalchemy import engine_from_config, pool -from logging.config import fileConfig - -# this is the Alembic Config object, which provides -# access to the values within the .ini file in use. -config = context.config - -# Interpret the config file for Python logging. -# This line sets up loggers basically. -#fileConfig("./alembic.ini") - -# add your model's MetaData object here -# for 'autogenerate' support -# from myapp import mymodel -# target_metadata = mymodel.Base.metadata -from flask import current_app -config.set_main_option('sqlalchemy.url', current_app.config.get('SQLALCHEMY_DATABASE_URI')) -target_metadata = current_app.extensions['migrate'].db.metadata - - -# other values from the config, defined by the needs of env.py, -# can be acquired: -# my_important_option = config.get_main_option("my_important_option") -# ... etc. - -def run_migrations_offline(): - """Run migrations in 'offline' mode. - - This configures the context with just a URL - and not an Engine, though an Engine is acceptable - here as well. By skipping the Engine creation - we don't even need a DBAPI to be available. - - Calls to context.execute() here emit the given string to the - script output. - - """ - url = config.get_main_option("sqlalchemy.url") - context.configure(url=url) - - with context.begin_transaction(): - context.run_migrations() - -def run_migrations_online(): - """Run migrations in 'online' mode. - - In this scenario we need to create an Engine - and associate a connection with the context. - - """ - connectable = engine_from_config( - config.get_section(config.config_ini_section), - prefix='sqlalchemy.', - poolclass=pool.NullPool) - - with connectable.connect() as connection: - context.configure( - connection=connection, - target_metadata=target_metadata - ) - - with context.begin_transaction(): - context.run_migrations() - -if context.is_offline_mode(): - run_migrations_offline() -else: - run_migrations_online() diff --git a/src/migrations/script.py.mako b/src/migrations/script.py.mako deleted file mode 100755 index 95702017..00000000 --- a/src/migrations/script.py.mako +++ /dev/null @@ -1,22 +0,0 @@ -"""${message} - -Revision ID: ${up_revision} -Revises: ${down_revision} -Create Date: ${create_date} - -""" - -# revision identifiers, used by Alembic. -revision = ${repr(up_revision)} -down_revision = ${repr(down_revision)} - -from alembic import op -import sqlalchemy as sa -${imports if imports else ""} - -def upgrade(): - ${upgrades if upgrades else "pass"} - - -def downgrade(): - ${downgrades if downgrades else "pass"} diff --git a/src/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py b/src/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py deleted file mode 100644 index 035646c6..00000000 --- a/src/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py +++ /dev/null @@ -1,34 +0,0 @@ -"""changed the type of the column 'last_modified' to string. - -Revision ID: 17dcb75f3fe -Revises: cde34831ea -Create Date: 2015-03-10 14:20:53.676344 - -""" - -# revision identifiers, used by Alembic. -revision = '17dcb75f3fe' -down_revision = 'cde34831ea' - -from datetime import datetime -import conf -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - unix_start = datetime(1970, 1, 1) - if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: - op.drop_column('feed', 'last_modified') - op.add_column('feed', sa.Column('last_modified', sa.String(), - nullable=True, default=unix_start, - server_default=str(unix_start))) - - -def downgrade(): - unix_start = datetime(1970, 1, 1) - if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: - op.drop_column('feed', 'last_modified') - op.add_column('feed', sa.Column('last_modified', sa.DateTime(), - nullable=True, default=unix_start, - server_default=unix_start)) diff --git a/src/migrations/versions/19bdaa6208e_add_icon_column.py b/src/migrations/versions/19bdaa6208e_add_icon_column.py deleted file mode 100644 index 2efa376f..00000000 --- a/src/migrations/versions/19bdaa6208e_add_icon_column.py +++ /dev/null @@ -1,26 +0,0 @@ -"""adding icon columns - -Revision ID: 19bdaa6208e -Revises: 422da2d0234 -Create Date: 2015-07-03 12:09:58.596010 - -""" - -# revision identifiers, used by Alembic. -revision = '19bdaa6208e' -down_revision = '422da2d0234' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.add_column('feed', sa.Column('icon', sa.String(), nullable=True)) - ### end Alembic commands ### - - -def downgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.drop_column('feed', 'icon') - ### end Alembic commands ### diff --git a/src/migrations/versions/1b750a389c22_remove_email_notification_column.py b/src/migrations/versions/1b750a389c22_remove_email_notification_column.py deleted file mode 100644 index 71529855..00000000 --- a/src/migrations/versions/1b750a389c22_remove_email_notification_column.py +++ /dev/null @@ -1,25 +0,0 @@ -"""remove email_notification column - -Revision ID: 1b750a389c22 -Revises: 48f561c0ce6 -Create Date: 2015-02-25 23:01:07.253429 - -""" - -# revision identifiers, used by Alembic. -revision = '1b750a389c22' -down_revision = '48f561c0ce6' - -import conf -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: - op.drop_column('feed', 'email_notification') - - -def downgrade(): - op.add_column('feed', sa.Column('email_notification', sa.Boolean(), - default=False)) diff --git a/src/migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py b/src/migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py deleted file mode 100644 index 2c8eeda5..00000000 --- a/src/migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py +++ /dev/null @@ -1,36 +0,0 @@ -"""moving icons to their own table - -Revision ID: 25ca960a207 -Revises: 19bdaa6208e -Create Date: 2015-08-03 14:36:21.626411 - -""" - -# revision identifiers, used by Alembic. -revision = '25ca960a207' -down_revision = '19bdaa6208e' - -from alembic import op -import sqlalchemy as sa - -import conf - - -def upgrade(): - op.create_table('icon', - sa.Column('url', sa.String(), nullable=False), - sa.Column('content', sa.String(), nullable=True), - sa.Column('mimetype', sa.String(), nullable=True), - sa.PrimaryKeyConstraint('url')) - op.add_column('feed', sa.Column('icon_url', sa.String(), nullable=True)) - if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: - op.create_foreign_key(None, 'feed', 'icon', ['icon_url'], ['url']) - op.drop_column('feed', 'icon') - - -def downgrade(): - op.add_column('feed', sa.Column('icon', sa.VARCHAR(), nullable=True)) - if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: - op.drop_constraint(None, 'feed', type_='foreignkey') - op.drop_column('feed', 'icon_url') - op.drop_table('icon') diff --git a/src/migrations/versions/3f83bfe93fc_adding_category.py b/src/migrations/versions/3f83bfe93fc_adding_category.py deleted file mode 100644 index b8412418..00000000 --- a/src/migrations/versions/3f83bfe93fc_adding_category.py +++ /dev/null @@ -1,42 +0,0 @@ -"""adding category - -Revision ID: 3f83bfe93fc -Revises: 25ca960a207 -Create Date: 2015-09-01 14:15:04.212563 -""" - -# revision identifiers, used by Alembic. -revision = '3f83bfe93fc' -down_revision = 'db64b766362f' - -import conf -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - op.create_table('category', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(), nullable=True), - sa.Column('user_id', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), - sa.PrimaryKeyConstraint('id')) - op.add_column('article', - sa.Column('category_id', sa.Integer(), nullable=True)) - op.add_column('feed', - sa.Column('category_id', sa.Integer(), nullable=True)) - if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: - op.create_foreign_key(None, 'article', 'category', - ['category_id'], ['id']) - op.create_foreign_key(None, 'feed', 'category', - ['category_id'], ['id']) - - -def downgrade(): - if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: - op.drop_constraint(None, 'feed', type_='foreignkey') - op.drop_constraint(None, 'feed', type_='foreignkey') - op.drop_column('feed', 'category_id') - op.drop_constraint(None, 'article', type_='foreignkey') - op.drop_column('article', 'category_id') - op.drop_table('category') diff --git a/src/migrations/versions/422da2d0234_adding_filters_field.py b/src/migrations/versions/422da2d0234_adding_filters_field.py deleted file mode 100644 index bcbdf042..00000000 --- a/src/migrations/versions/422da2d0234_adding_filters_field.py +++ /dev/null @@ -1,22 +0,0 @@ -"""adding filters field - -Revision ID: 422da2d0234 -Revises: 17dcb75f3fe -Create Date: 2015-05-18 23:03:15.809549 - -""" - -# revision identifiers, used by Alembic. -revision = '422da2d0234' -down_revision = '17dcb75f3fe' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - op.add_column('feed', sa.Column('filters', sa.PickleType(), nullable=True)) - - -def downgrade(): - op.drop_column('feed', 'filters') diff --git a/src/migrations/versions/48f561c0ce6_add_column_entry_id.py b/src/migrations/versions/48f561c0ce6_add_column_entry_id.py deleted file mode 100644 index f464849a..00000000 --- a/src/migrations/versions/48f561c0ce6_add_column_entry_id.py +++ /dev/null @@ -1,26 +0,0 @@ -"""add column entry_id - -Revision ID: 48f561c0ce6 -Revises: -Create Date: 2015-02-18 21:17:19.346998 - -""" - -# revision identifiers, used by Alembic. -revision = '48f561c0ce6' -down_revision = None -branch_labels = None -depends_on = None - -import conf -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - op.add_column('article', sa.Column('entry_id', sa.String(), nullable=True)) - - -def downgrade(): - if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: - op.drop_column('article', 'entry_id') diff --git a/src/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py b/src/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py deleted file mode 100644 index 8763f925..00000000 --- a/src/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py +++ /dev/null @@ -1,44 +0,0 @@ -"""adding feed and user attributes for better feed retreiving - -Revision ID: cde34831ea -Revises: 1b750a389c22 -Create Date: 2015-03-04 22:59:44.665979 - -""" - -# revision identifiers, used by Alembic. -revision = 'cde34831ea' -down_revision = '1b750a389c22' -import conf -from datetime import datetime - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - unix_start = datetime(1970, 1, 1) - # commands auto generated by Alembic - please adjust! ### - op.add_column('feed', sa.Column('error_count', sa.Integer(), nullable=True, - default=0, server_default="0")) - op.add_column('feed', sa.Column('last_error', sa.String(), nullable=True)) - op.add_column('feed', sa.Column('last_modified', sa.DateTime(), - nullable=True, default=unix_start, server_default=str(unix_start))) - op.add_column('feed', sa.Column('last_retrieved', sa.DateTime(), - nullable=True, default=unix_start, server_default=str(unix_start))) - op.add_column('feed', sa.Column('etag', sa.String(), nullable=True)) - op.add_column('user', sa.Column('refresh_rate', sa.Integer(), - nullable=True, default=60)) - # end Alembic commands ### - - -def downgrade(): - # commands auto generated by Alembic - please adjust! ### - if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: - op.drop_column('user', 'refresh_rate') - op.drop_column('feed', 'last_modified') - op.drop_column('feed', 'last_error') - op.drop_column('feed', 'error_count') - op.drop_column('feed', 'last_retrieved') - op.drop_column('feed', 'etag') - # end Alembic commands ### diff --git a/src/migrations/versions/db64b766362f_add_notes_column_for_articles.py b/src/migrations/versions/db64b766362f_add_notes_column_for_articles.py deleted file mode 100644 index 3d25b004..00000000 --- a/src/migrations/versions/db64b766362f_add_notes_column_for_articles.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Add notes column for articles. - -Revision ID: db64b766362f -Revises: 25ca960a207 -Create Date: 2016-01-06 19:03:25.511074 - -""" - -# revision identifiers, used by Alembic. -revision = 'db64b766362f' -down_revision = '25ca960a207' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - op.add_column('article', sa.Column('notes', sa.String(), nullable=True)) - - -def downgrade(): - op.drop_column('article', 'notes') diff --git a/src/migrations1/README b/src/migrations1/README new file mode 100644 index 00000000..98e4f9c4 --- /dev/null +++ b/src/migrations1/README @@ -0,0 +1 @@ +Generic single-database configuration. \ No newline at end of file diff --git a/src/migrations1/env.py b/src/migrations1/env.py new file mode 100644 index 00000000..058378b9 --- /dev/null +++ b/src/migrations1/env.py @@ -0,0 +1,70 @@ +from __future__ import with_statement +from alembic import context +from sqlalchemy import engine_from_config, pool +from logging.config import fileConfig + +# this is the Alembic Config object, which provides +# access to the values within the .ini file in use. +config = context.config + +# Interpret the config file for Python logging. +# This line sets up loggers basically. +fileConfig(config.config_file_name) + +# add your model's MetaData object here +# for 'autogenerate' support +# from myapp import mymodel +# target_metadata = mymodel.Base.metadata +target_metadata = None + +# other values from the config, defined by the needs of env.py, +# can be acquired: +# my_important_option = config.get_main_option("my_important_option") +# ... etc. + + +def run_migrations_offline(): + """Run migrations in 'offline' mode. + + This configures the context with just a URL + and not an Engine, though an Engine is acceptable + here as well. By skipping the Engine creation + we don't even need a DBAPI to be available. + + Calls to context.execute() here emit the given string to the + script output. + + """ + url = config.get_main_option("sqlalchemy.url") + context.configure( + url=url, target_metadata=target_metadata, literal_binds=True) + + with context.begin_transaction(): + context.run_migrations() + + +def run_migrations_online(): + """Run migrations in 'online' mode. + + In this scenario we need to create an Engine + and associate a connection with the context. + + """ + connectable = engine_from_config( + config.get_section(config.config_ini_section), + prefix='sqlalchemy.', + poolclass=pool.NullPool) + + with connectable.connect() as connection: + context.configure( + connection=connection, + target_metadata=target_metadata + ) + + with context.begin_transaction(): + context.run_migrations() + +if context.is_offline_mode(): + run_migrations_offline() +else: + run_migrations_online() diff --git a/src/migrations1/script.py.mako b/src/migrations1/script.py.mako new file mode 100644 index 00000000..43c09401 --- /dev/null +++ b/src/migrations1/script.py.mako @@ -0,0 +1,24 @@ +"""${message} + +Revision ID: ${up_revision} +Revises: ${down_revision | comma,n} +Create Date: ${create_date} + +""" + +# revision identifiers, used by Alembic. +revision = ${repr(up_revision)} +down_revision = ${repr(down_revision)} +branch_labels = ${repr(branch_labels)} +depends_on = ${repr(depends_on)} + +from alembic import op +import sqlalchemy as sa +${imports if imports else ""} + +def upgrade(): + ${upgrades if upgrades else "pass"} + + +def downgrade(): + ${downgrades if downgrades else "pass"} -- cgit