diff options
-rw-r--r--[-rwxr-xr-x] | migrations/README (renamed from src/migrations/README) | 0 | ||||
-rw-r--r-- | migrations/alembic.ini (renamed from src/migrations/alembic.ini) | 23 | ||||
-rw-r--r-- | migrations/env.py (renamed from src/migrations/env.py) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | migrations/script.py.mako (renamed from src/migrations/script.py.mako) | 4 | ||||
-rw-r--r-- | migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py (renamed from src/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py) | 0 | ||||
-rw-r--r-- | migrations/versions/19bdaa6208e_add_icon_column.py (renamed from src/migrations/versions/19bdaa6208e_add_icon_column.py) | 0 | ||||
-rw-r--r-- | migrations/versions/1b750a389c22_remove_email_notification_column.py (renamed from src/migrations/versions/1b750a389c22_remove_email_notification_column.py) | 0 | ||||
-rw-r--r-- | migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py (renamed from src/migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py) | 0 | ||||
-rw-r--r-- | migrations/versions/422da2d0234_adding_filters_field.py (renamed from src/migrations/versions/422da2d0234_adding_filters_field.py) | 0 | ||||
-rw-r--r-- | migrations/versions/48f561c0ce6_add_column_entry_id.py (renamed from src/migrations/versions/48f561c0ce6_add_column_entry_id.py) | 0 | ||||
-rw-r--r-- | migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py (renamed from src/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py) | 0 | ||||
-rw-r--r-- | src/alembic.ini | 68 | ||||
-rw-r--r-- | src/migrations/versions/3f83bfe93fc_adding_category.py | 42 | ||||
-rw-r--r-- | src/migrations/versions/db64b766362f_add_notes_column_for_articles.py | 22 | ||||
-rw-r--r-- | src/migrations1/README | 1 | ||||
-rw-r--r-- | src/migrations1/env.py | 70 | ||||
-rw-r--r-- | src/migrations1/script.py.mako | 24 |
17 files changed, 189 insertions, 65 deletions
diff --git a/src/migrations/README b/migrations/README index 98e4f9c4..98e4f9c4 100755..100644 --- a/src/migrations/README +++ b/migrations/README diff --git a/src/migrations/alembic.ini b/migrations/alembic.ini index f8ed4801..1c105dc6 100644 --- a/src/migrations/alembic.ini +++ b/migrations/alembic.ini @@ -1,13 +1,36 @@ # 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] diff --git a/src/migrations/env.py b/migrations/env.py index 7215fefe..7215fefe 100644 --- a/src/migrations/env.py +++ b/migrations/env.py diff --git a/src/migrations/script.py.mako b/migrations/script.py.mako index 95702017..43c09401 100755..100644 --- a/src/migrations/script.py.mako +++ b/migrations/script.py.mako @@ -1,7 +1,7 @@ """${message} Revision ID: ${up_revision} -Revises: ${down_revision} +Revises: ${down_revision | comma,n} Create Date: ${create_date} """ @@ -9,6 +9,8 @@ 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 diff --git a/src/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py b/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py index 035646c6..035646c6 100644 --- a/src/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py +++ b/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py diff --git a/src/migrations/versions/19bdaa6208e_add_icon_column.py b/migrations/versions/19bdaa6208e_add_icon_column.py index 2efa376f..2efa376f 100644 --- a/src/migrations/versions/19bdaa6208e_add_icon_column.py +++ b/migrations/versions/19bdaa6208e_add_icon_column.py diff --git a/src/migrations/versions/1b750a389c22_remove_email_notification_column.py b/migrations/versions/1b750a389c22_remove_email_notification_column.py index 71529855..71529855 100644 --- a/src/migrations/versions/1b750a389c22_remove_email_notification_column.py +++ b/migrations/versions/1b750a389c22_remove_email_notification_column.py diff --git a/src/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 index 2c8eeda5..2c8eeda5 100644 --- a/src/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 diff --git a/src/migrations/versions/422da2d0234_adding_filters_field.py b/migrations/versions/422da2d0234_adding_filters_field.py index bcbdf042..bcbdf042 100644 --- a/src/migrations/versions/422da2d0234_adding_filters_field.py +++ b/migrations/versions/422da2d0234_adding_filters_field.py diff --git a/src/migrations/versions/48f561c0ce6_add_column_entry_id.py b/migrations/versions/48f561c0ce6_add_column_entry_id.py index f464849a..f464849a 100644 --- a/src/migrations/versions/48f561c0ce6_add_column_entry_id.py +++ b/migrations/versions/48f561c0ce6_add_column_entry_id.py diff --git a/src/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py b/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py index 8763f925..8763f925 100644 --- a/src/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py +++ b/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py 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/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/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"} |