remove Alembic, too confusing

This commit is contained in:
Kyle Mahan 2015-08-27 20:56:34 -07:00
parent 61b28ef654
commit 46e98853d9
8 changed files with 8 additions and 274 deletions

View file

@ -1,12 +0,0 @@
#!/usr/bin/env python
from woodwind import create_app
from flask.ext.script import Manager
from flask.ext.migrate import MigrateCommand
app = create_app()
manager = Manager(app)
manager.add_command('db', MigrateCommand)
if __name__ == '__main__':
manager.run()

View file

@ -1 +0,0 @@
Generic single-database configuration.

View file

@ -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

View file

@ -1,73 +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(config.config_file_name)
# 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.
"""
engine = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()

View file

@ -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"}

View file

@ -1,74 +0,0 @@
"""empty message
Revision ID: 564f5a5061f
Revises: 5824a5f06dd
Create Date: 2015-04-19 07:49:24.416817
"""
# revision identifiers, used by Alembic.
revision = '564f5a5061f'
down_revision = '5824a5f06dd'
from alembic import op
import sqlalchemy as sa
from woodwind.models import JsonType
def upgrade():
### commands auto generated by Alembic - please adjust! ###
subsc = op.create_table(
'subscription',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), sa.ForeignKey('user.id'), nullable=False),
sa.Column('feed_id', sa.Integer(), sa.ForeignKey('feed.id'), nullable=False),
sa.Column('name', sa.String(length=256), nullable=True),
sa.Column('tags', sa.String(length=256), nullable=True),
sa.PrimaryKeyConstraint('id')
)
feed = sa.table(
'feed',
sa.column('id', sa.Integer()),
sa.column('name', sa.String()))
u2f = sa.table(
'users_to_feeds',
sa.column('user_id', sa.Integer()),
sa.column('feed_id', sa.Integer()))
values = sa.select(
[u2f.c.user_id, u2f.c.feed_id, feed.c.name]
).select_from(
u2f.join(feed, feed.c.id == u2f.c.feed_id)
)
op.execute(subsc.insert().from_select(
['user_id', 'feed_id', 'name'], values))
op.drop_table('users_to_feeds')
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
u2f = op.create_table(
'users_to_feeds',
sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('feed_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['feed_id'], ['feed.id'], name='users_to_feeds_feed_id_fkey'),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], name='users_to_feeds_user_id_fkey')
)
subsc = sa.table(
'subscription',
sa.Column('user_id', sa.Integer()),
sa.Column('feed_id', sa.Integer()),
)
op.execute(u2f.insert().from_select(
['user_id', 'feed_id'],
sa.select([subsc.c.user_id, subsc.c.feed_id])))
op.drop_table('subscription')
### end Alembic commands ###

View file

@ -1,36 +0,0 @@
"""empty message
Revision ID: 5824a5f06dd
Revises: None
Create Date: 2015-04-19 07:45:58.410077
"""
# revision identifiers, used by Alembic.
revision = '5824a5f06dd'
down_revision = None
from alembic import op
import sqlalchemy as sa
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_index(op.f('ix_entry_feed_id'), 'entry', ['feed_id'], unique=False)
op.create_index(op.f('ix_entry_permalink'), 'entry', ['permalink'], unique=False)
op.create_index(op.f('ix_entry_retrieved'), 'entry', ['retrieved'], unique=False)
op.drop_index('entry_feed_id_idx', table_name='entry')
op.drop_index('entry_permalink_idx', table_name='entry')
op.drop_index('entry_retrieved_idx', table_name='entry')
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_index('entry_retrieved_idx', 'entry', ['retrieved'], unique=False)
op.create_index('entry_permalink_idx', 'entry', ['permalink'], unique=False)
op.create_index('entry_feed_id_idx', 'entry', ['feed_id'], unique=False)
op.drop_index(op.f('ix_entry_retrieved'), table_name='entry')
op.drop_index(op.f('ix_entry_permalink'), table_name='entry')
op.drop_index(op.f('ix_entry_feed_id'), table_name='entry')
### end Alembic commands ###

View file

@ -2,34 +2,31 @@ Flask==0.10.1
Flask-DebugToolbar==0.10.0
Flask-Login==0.2.11
Flask-Micropub==0.2.2
Flask-Migrate==1.3.1
Flask-SQLAlchemy==2.0
Flask-Script==2.0.5
Jinja2==2.7.3
MarkupSafe==0.23
SQLAlchemy==1.0.0
Werkzeug==0.10.4
alembic==0.7.6
asyncio-redis==0.13.4
beautifulsoup4==4.3.2
bleach==1.4.1
blinker==1.3
cffi==0.9.2
click==4.0
cryptography==0.8.2
feedparser>=5.2.0
html5lib==0.99999
itsdangerous==0.24
mf2py==0.2.6
mf2util==0.1.9
psycopg2==2.6
pyOpenSSL==0.15.1
pyasn1==0.1.7
pycparser==2.10
redis==2.10.3
requests==2.7.0
rq==0.5.2
six==1.9.0
uWSGI==2.0.10
websockets==2.4
sgmllib3k==1.0.0