Skip to content

Commit

Permalink
columns cleanup, refs #142
Browse files Browse the repository at this point in the history
  • Loading branch information
kkamkou committed Nov 6, 2016
1 parent 673e372 commit f7c68bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 25 deletions.
6 changes: 3 additions & 3 deletions gitmostwanted/models/repo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sqlalchemy.dialects.mysql import SMALLINT
from sqlalchemy.dialects.mysql import INTEGER, SMALLINT
from sqlalchemy.sql import expression
from gitmostwanted.lib.status import Status
from gitmostwanted.lib.regex import SearchTerm
Expand All @@ -22,8 +22,8 @@ class Repo(db.Model):
created_at = db.Column(db.DateTime, nullable=False, index=True)
checked_at = db.Column(db.DateTime, index=True)
mature = db.Column(db.Boolean, nullable=False, server_default=expression.false(), index=True)
worth = db.Column(SMALLINT(display_width=1), nullable=False, server_default='3', index=True)
stargazers_count = db.Column(db.Integer, nullable=False, server_default='0')
worth = db.Column(SMALLINT(display_width=2), nullable=False, server_default='3', index=True)
stargazers_count = db.Column(INTEGER(unsigned=True), nullable=False, server_default='0')
status_updated_at = db.Column(db.DateTime)
status = db.Column(
db.Enum('promising', 'new', 'unknown', 'deleted', 'hopeless'),
Expand Down
34 changes: 12 additions & 22 deletions migration/env.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from gitmostwanted.app import app
from logging.config import fileConfig
from gitmostwanted.app import app, db
from sqlalchemy import engine_from_config, pool
from alembic import context

# models
from gitmostwanted.models.repo import *
from gitmostwanted.models.user import *
from gitmostwanted.models.report import *

# this is the Alembic Config object, which provides
Expand All @@ -31,6 +28,8 @@
# my_important_option = config.get_main_option("my_important_option")
# ... etc.

config_custom = dict(target_metadata=target_metadata, compare_type=True)


def run_migrations_offline():
"""Run migrations in 'offline' mode.
Expand All @@ -44,9 +43,7 @@ def run_migrations_offline():
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(url=url, target_metadata=target_metadata)

context.configure(url=config.get_main_option("sqlalchemy.url"), **config_custom)
with context.begin_transaction():
context.run_migrations()

Expand All @@ -58,21 +55,14 @@ def run_migrations_online():
and associate a connection with the context.
"""
connectable = engine_from_config(
connectible = 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
)

poolclass=pool.NullPool
)
with connectible.connect() as connection:
context.configure(connection=connection, **config_custom)
with context.begin_transaction():
context.run_migrations()

if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
run_migrations_offline() if context.is_offline_mode() else run_migrations_online()

0 comments on commit f7c68bf

Please sign in to comment.