Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix migration for mysql to enable mysql CI #475

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ mysql_test: bin/py.test
mysql -u jenkins_bookie --password=bookie -e "DROP DATABASE jenkins_bookie;"
mysql -u jenkins_bookie --password=bookie -e "CREATE DATABASE jenkins_bookie;"
bin/alembic -c test_alembic_mysql.ini upgrade head
BOOKIE_TEST_INI=test_mysql.ini $(NOSE) -xv --with-coverage --cover-package=bookie --cover-erase --with-xunit bookie/tests
BOOKIE_TEST_INI=test_mysql.ini INI="test_mysql.ini" NLTK_DATA=$(NLTK_DATA) $(PYTEST) -s bookie/tests

.PHONY: pgsql_test
pgsql_test: bin/py.test
Expand Down
20 changes: 13 additions & 7 deletions dbversions/versions/44dccb7b8b82_update_username_to_l.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""update username to lowercase
'''update username to lowercase

Revision ID: 44dccb7b8b82
Revises: 9f274a38d84
Create Date: 2014-02-27 00:55:59.913206

"""
'''

# revision identifiers, used by Alembic.
revision = '44dccb7b8b82'
Expand All @@ -22,9 +22,10 @@ def upgrade():
bmarks = sa.Table('bmarks', meta, autoload=True)

try:
op.drop_constraint("bmarks_username_fkey", "bmarks")
op.drop_index('bmarks_username_fkey', 'bmarks', 'unique')
op.drop_constraint('bmarks_username_fkey', 'bmarks', 'foreignkey')
print 'dropped constraint'
except (sa.exc.OperationalError, NotImplementedError) as exc:
except (sa.exc.OperationalError, NotImplementedError):
# If it's not supported then pass
pass

Expand All @@ -45,12 +46,17 @@ def upgrade():
print 'done user: ' + user['username']

try:
op.create_index(
'bmarks_username_fkey',
'bmarks',
['username', 'hash_id'],
'unique')
op.create_foreign_key(
"bmarks_username_fkey", "bmarks",
"users", ["username"], ["username"])
'bmarks_username_fkey', 'bmarks',
'users', ['username'], ['username'])

print 'added constraint'
except (sa.exc.OperationalError, NotImplementedError) as exc:
except (sa.exc.OperationalError, NotImplementedError):
# If it's not supported then pass
pass

Expand Down
36 changes: 24 additions & 12 deletions dbversions/versions/5920b225d05d_load_up_to_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('users',
op.create_table(
'users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.Unicode(length=255), nullable=True),
sa.Column('name', sa.Unicode(length=255), nullable=True),
Expand All @@ -36,21 +37,24 @@ def upgrade():
sa.UniqueConstraint('username')
)

op.create_table('tags',
op.create_table(
'tags',
sa.Column('tid', sa.Integer(), nullable=False),
sa.Column('name', sa.Unicode(length=255), nullable=True),
sa.PrimaryKeyConstraint('tid'),
sa.UniqueConstraint('name')
)

op.create_table('url_hash',
op.create_table(
'url_hash',
sa.Column('hash_id', sa.Unicode(length=22), nullable=False),
sa.Column('url', sa.UnicodeText(), nullable=True),
sa.Column('clicks', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('hash_id')
)

op.create_table('bmarks',
op.create_table(
'bmarks',
sa.Column('bid', sa.Integer(), nullable=False),
sa.Column('hash_id', sa.Unicode(length=22), nullable=True),
sa.Column('description', sa.UnicodeText(), nullable=True),
Expand All @@ -61,13 +65,16 @@ def upgrade():
sa.Column('inserted_by', sa.Unicode(length=255), nullable=True),
sa.Column('username', sa.Unicode(length=255), nullable=False),
sa.Column('tag_str', sa.UnicodeText(), nullable=True),
sa.ForeignKeyConstraint(['hash_id'], ['url_hash.hash_id'], ),
sa.ForeignKeyConstraint(['username'], ['users.username'], ),
sa.ForeignKeyConstraint(
['hash_id'], ['url_hash.hash_id'], name="bmarks_hash_id_fkey"),
sa.ForeignKeyConstraint(
['username'], ['users.username'], name="bmarks_username_fkey"),
sa.UniqueConstraint('username', 'hash_id'),
sa.PrimaryKeyConstraint('bid'),
)

op.create_table(u'activations',
op.create_table(
u'activations',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('code', sa.Unicode(length=60), nullable=True),
sa.Column('valid_until', sa.DateTime(), nullable=True),
Expand All @@ -76,15 +83,17 @@ def upgrade():
sa.PrimaryKeyConstraint('id')
)

op.create_table('bmark_tags',
op.create_table(
'bmark_tags',
sa.Column('bmark_id', sa.Integer(), nullable=False),
sa.Column('tag_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['bmark_id'], ['bmarks.bid'], ),
sa.ForeignKeyConstraint(['tag_id'], ['tags.tid'], ),
sa.PrimaryKeyConstraint('bmark_id', 'tag_id')
)

op.create_table('logging',
op.create_table(
'logging',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user', sa.Unicode(255), nullable=False),
sa.Column('component', sa.Unicode(50), nullable=False),
Expand All @@ -95,7 +104,8 @@ def upgrade():
sa.PrimaryKeyConstraint('id'),
)

op.create_table('import_queue',
op.create_table(
'import_queue',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.Unicode(255)),
sa.Column('file_path', sa.Unicode(100), nullable=False),
Expand All @@ -105,15 +115,17 @@ def upgrade():
sa.PrimaryKeyConstraint('id'),
)

op.create_table('stats_bookmarks',
op.create_table(
'stats_bookmarks',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('tstamp', sa.DateTime),
sa.Column('attrib', sa.Unicode(100), nullable=False),
sa.Column('data', sa.Integer),
sa.PrimaryKeyConstraint('id'),
)

op.create_table('bmark_readable',
op.create_table(
'bmark_readable',
sa.Column('bid', sa.Integer(), nullable=False, index=True),
sa.Column('hash_id', sa.Unicode(length=22), nullable=True),
sa.Column('content', sa.UnicodeText(), nullable=True),
Expand Down
27 changes: 21 additions & 6 deletions test_mysql.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ combo_server=127.0.0.1:8000
combo_cache_id=

# file to include on each page that includes things such as google analytics code
installspecific =
installspecific = /home/rharding/src/bookie/bookie/installspecific.txt

# Where are we going to upload import files while we wait to process them
# we leave this commented out in tests, just let it use the default tmp dir
#import_files=%(here)s/data/imports

celery_broker=redis://localhost:6379/9
celery_concurrency=1

# Where are we going to upload import files while we wait to process them
import_files={here}/data/imports

[server:main]
use = egg:Paste#http
Expand All @@ -41,7 +46,7 @@ port = 6543
# Begin logging configuration

[loggers]
keys = root, bookie, sqlalchemy
keys = root, bookie, celery, breadability

[handlers]
keys = console
Expand All @@ -50,16 +55,26 @@ keys = console
keys = generic

[logger_root]
level = DEBUG
level = INFO
handlers = console

[logger_bookie]
level = DEBUG
level = WARN
handlers =
qualname = bookie

[logger_breadability]
level = WARN
handlers =
qualname = breadability

[logger_celery]
level = WARN
handlers =
qualname = bookie.bcelery.tasks

[logger_sqlalchemy]
level = DEBUG
level = WARN
handlers = console
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
Expand All @@ -69,7 +84,7 @@ qualname = sqlalchemy.engine
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = DEBUG
level = INFO
formatter = generic

[formatter_generic]
Expand Down