Commit f067753f authored by Robin Sonnabend's avatar Robin Sonnabend

Change string format for mysql-compatibility

parent a80e8b36
Generic single-database configuration.
\ No newline at end of file
# 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
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
import logging
# 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)
logger = logging.getLogger('alembic.env')
# 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.
"""
# this callback is used to prevent an auto-migration from being generated
# when there are no changes to the schema
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
def process_revision_directives(context, revision, directives):
if getattr(config.cmd_opts, 'autogenerate', False):
script = directives[0]
if script.upgrade_ops.is_empty():
directives[:] = []
logger.info('No changes in schema detected.')
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,
process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
branch_labels = ${repr(branch_labels)}
depends_on = ${repr(depends_on)}
def upgrade():
${upgrades if upgrades else "pass"}
def downgrade():
${downgrades if downgrades else "pass"}
"""empty message
Revision ID: 841fb7253188
Revises:
Create Date: 2018-11-09 18:49:39.933529
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '841fb7253188'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('protocoltypes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=128), nullable=True),
sa.Column('short_name', sa.String(length=128), nullable=True),
sa.Column('organization', sa.Text(), nullable=True),
sa.Column('usual_time', sa.Time(), nullable=True),
sa.Column('is_public', sa.Boolean(), nullable=True),
sa.Column('modify_group', sa.Text(), nullable=True),
sa.Column('private_group', sa.Text(), nullable=True),
sa.Column('public_group', sa.Text(), nullable=True),
sa.Column('publish_group', sa.Text(), nullable=True),
sa.Column('private_mail', sa.Text(), nullable=True),
sa.Column('public_mail', sa.Text(), nullable=True),
sa.Column('non_reproducible_pad_links', sa.Boolean(), nullable=True),
sa.Column('use_wiki', sa.Boolean(), nullable=True),
sa.Column('wiki_category', sa.Text(), nullable=True),
sa.Column('wiki_only_public', sa.Boolean(), nullable=True),
sa.Column('printer', sa.Text(), nullable=True),
sa.Column('calendar', sa.Text(), nullable=True),
sa.Column('restrict_networks', sa.Boolean(), nullable=True),
sa.Column('allowed_networks', sa.Text(), nullable=True),
sa.Column('latex_template', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name'),
sa.UniqueConstraint('short_name')
)
op.create_table('todomails',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=128), nullable=True),
sa.Column('mail', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
op.create_table('decisioncategories',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('protocoltype_id', sa.Integer(), nullable=True),
sa.Column('name', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['protocoltype_id'], ['protocoltypes.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('defaultmetas',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('protocoltype_id', sa.Integer(), nullable=True),
sa.Column('key', sa.Text(), nullable=True),
sa.Column('name', sa.Text(), nullable=True),
sa.Column('value', sa.Text(), nullable=True),
sa.Column('internal', sa.Boolean(), nullable=True),
sa.Column('prior', sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(['protocoltype_id'], ['protocoltypes.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('defaulttops',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('protocoltype_id', sa.Integer(), nullable=True),
sa.Column('name', sa.Text(), nullable=True),
sa.Column('number', sa.Integer(), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['protocoltype_id'], ['protocoltypes.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('meetingreminders',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('protocoltype_id', sa.Integer(), nullable=True),
sa.Column('days_before', sa.Integer(), nullable=True),
sa.Column('send_public', sa.Boolean(), nullable=True),
sa.Column('send_private', sa.Boolean(), nullable=True),
sa.Column('additional_text', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['protocoltype_id'], ['protocoltypes.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('protocols',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('protocoltype_id', sa.Integer(), nullable=True),
sa.Column('source', sa.Text(), nullable=True),
sa.Column('content_public', sa.Text(), nullable=True),
sa.Column('content_private', sa.Text(), nullable=True),
sa.Column('content_html_public', sa.Text(), nullable=True),
sa.Column('content_html_private', sa.Text(), nullable=True),
sa.Column('date', sa.Date(), nullable=True),
sa.Column('start_time', sa.Time(), nullable=True),
sa.Column('end_time', sa.Time(), nullable=True),
sa.Column('done', sa.Boolean(), nullable=False),
sa.Column('public', sa.Boolean(), nullable=True),
sa.Column('pad_identifier', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['protocoltype_id'], ['protocoltypes.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('todos',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('protocoltype_id', sa.Integer(), nullable=True),
sa.Column('number', sa.Integer(), nullable=True),
sa.Column('who', sa.Text(), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('state', sa.Enum('open', 'waiting', 'in_progress', 'after', 'before', 'orphan', 'done', 'rejected', 'obsolete', name='todostate'), nullable=False),
sa.Column('date', sa.Date(), nullable=True),
sa.ForeignKeyConstraint(['protocoltype_id'], ['protocoltypes.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('decisions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('protocol_id', sa.Integer(), nullable=True),
sa.Column('content', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['protocol_id'], ['protocols.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('documents',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('protocol_id', sa.Integer(), nullable=True),
sa.Column('name', sa.Text(), nullable=True),
sa.Column('filename', sa.Text(), nullable=True),
sa.Column('is_compiled', sa.Boolean(), nullable=True),
sa.Column('is_private', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['protocol_id'], ['protocols.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('errors',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('protocol_id', sa.Integer(), nullable=True),
sa.Column('action', sa.Text(), nullable=True),
sa.Column('name', sa.Text(), nullable=True),
sa.Column('datetime', sa.DateTime(), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['protocol_id'], ['protocols.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('likeprotocolassociations',
sa.Column('like_id', sa.Integer(), nullable=False),
sa.Column('protocol_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['like_id'], ['likes.id'], ),
sa.ForeignKeyConstraint(['protocol_id'], ['protocols.id'], ),
sa.PrimaryKeyConstraint('like_id', 'protocol_id')
)
op.create_table('liketodoassociations',
sa.Column('like_id', sa.Integer(), nullable=False),
sa.Column('todo_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['like_id'], ['likes.id'], ),
sa.ForeignKeyConstraint(['todo_id'], ['todos.id'], ),
sa.PrimaryKeyConstraint('like_id', 'todo_id')
)
op.create_table('localtops',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('protocol_id', sa.Integer(), nullable=True),
sa.Column('defaulttop_id', sa.Integer(), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['defaulttop_id'], ['defaulttops.id'], ),
sa.ForeignKeyConstraint(['protocol_id'], ['protocols.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('metas',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('protocol_id', sa.Integer(), nullable=True),
sa.Column('name', sa.Text(), nullable=True),
sa.Column('value', sa.Text(), nullable=True),
sa.Column('internal', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['protocol_id'], ['protocols.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('todoprotocolassociations',
sa.Column('todo_id', sa.Integer(), nullable=False),
sa.Column('protocol_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['protocol_id'], ['protocols.id'], ),
sa.ForeignKeyConstraint(['todo_id'], ['todos.id'], ),
sa.PrimaryKeyConstraint('todo_id', 'protocol_id')
)
op.create_table('tops',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('protocol_id', sa.Integer(), nullable=True),
sa.Column('name', sa.Text(), nullable=True),
sa.Column('number', sa.Integer(), nullable=True),
sa.Column('planned', sa.Boolean(), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['protocol_id'], ['protocols.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('decisioncategoryassociations',
sa.Column('decision_id', sa.Integer(), nullable=False),
sa.Column('decisioncategory_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['decision_id'], ['decisions.id'], ),
sa.ForeignKeyConstraint(['decisioncategory_id'], ['decisioncategories.id'], ),
sa.PrimaryKeyConstraint('decision_id', 'decisioncategory_id')
)
op.create_table('decisiondocuments',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('decision_id', sa.Integer(), nullable=True),
sa.Column('name', sa.Text(), nullable=True),
sa.Column('filename', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['decision_id'], ['decisions.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('likedecisionassociations',
sa.Column('like_id', sa.Integer(), nullable=False),
sa.Column('decision_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['decision_id'], ['decisions.id'], ),
sa.ForeignKeyConstraint(['like_id'], ['likes.id'], ),
sa.PrimaryKeyConstraint('like_id', 'decision_id')
)
op.create_table('liketopassociations',
sa.Column('like_id', sa.Integer(), nullable=False),
sa.Column('top_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['like_id'], ['likes.id'], ),
sa.ForeignKeyConstraint(['top_id'], ['tops.id'], ),
sa.PrimaryKeyConstraint('like_id', 'top_id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('liketopassociations')
op.drop_table('likedecisionassociations')
op.drop_table('decisiondocuments')
op.drop_table('decisioncategoryassociations')
op.drop_table('tops')
op.drop_table('todoprotocolassociations')
op.drop_table('metas')
op.drop_table('localtops')
op.drop_table('liketodoassociations')
op.drop_table('likeprotocolassociations')
op.drop_table('errors')
op.drop_table('documents')
op.drop_table('decisions')
op.drop_table('todos')
op.drop_table('protocols')
op.drop_table('meetingreminders')
op.drop_table('defaulttops')
op.drop_table('defaultmetas')
op.drop_table('decisioncategories')
op.drop_table('todomails')
op.drop_table('protocoltypes')
# ### end Alembic commands ###
......@@ -57,26 +57,26 @@ class ProtocolType(DatabaseModel):
__tablename__ = "protocoltypes"
__model_name__ = "protocoltype"
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String, unique=True)
short_name = db.Column(db.String, unique=True)
organization = db.Column(db.String)
name = db.Column(db.String(128), unique=True)
short_name = db.Column(db.String(128), unique=True)
organization = db.Column(db.Text)
usual_time = db.Column(db.Time)
is_public = db.Column(db.Boolean)
modify_group = db.Column(db.String)
private_group = db.Column(db.String)
public_group = db.Column(db.String)
publish_group = db.Column(db.String)
private_mail = db.Column(db.String)
public_mail = db.Column(db.String)
modify_group = db.Column(db.Text)
private_group = db.Column(db.Text)
public_group = db.Column(db.Text)
publish_group = db.Column(db.Text)
private_mail = db.Column(db.Text)
public_mail = db.Column(db.Text)
non_reproducible_pad_links = db.Column(db.Boolean)
use_wiki = db.Column(db.Boolean)
wiki_category = db.Column(db.String)
wiki_category = db.Column(db.Text)
wiki_only_public = db.Column(db.Boolean)
printer = db.Column(db.String)
calendar = db.Column(db.String)
printer = db.Column(db.Text)
calendar = db.Column(db.Text)
restrict_networks = db.Column(db.Boolean)
allowed_networks = db.Column(db.String)
latex_template = db.Column(db.String)
allowed_networks = db.Column(db.Text)
latex_template = db.Column(db.Text)
protocols = relationship(
"Protocol", backref=backref("protocoltype"),
......@@ -187,17 +187,17 @@ class Protocol(DatabaseModel):
__model_name__ = "protocol"
id = db.Column(db.Integer, primary_key=True)
protocoltype_id = db.Column(db.Integer, db.ForeignKey("protocoltypes.id"))
source = db.Column(db.String)
content_public = db.Column(db.String)
content_private = db.Column(db.String)
content_html_public = db.Column(db.String)
content_html_private = db.Column(db.String)
source = db.Column(db.Text)
content_public = db.Column(db.Text)
content_private = db.Column(db.Text)
content_html_public = db.Column(db.Text)
content_html_private = db.Column(db.Text)
date = db.Column(db.Date)
start_time = db.Column(db.Time)
end_time = db.Column(db.Time)
done = db.Column(db.Boolean, nullable=False, default=False)
public = db.Column(db.Boolean)
pad_identifier = db.Column(db.String)
pad_identifier = db.Column(db.Text)
tops = relationship(
"TOP", backref=backref("protocol"),
......@@ -464,9 +464,9 @@ class DefaultTOP(DatabaseModel):
__model_name__ = "defaulttop"
id = db.Column(db.Integer, primary_key=True)
protocoltype_id = db.Column(db.Integer, db.ForeignKey("protocoltypes.id"))
name = db.Column(db.String)
name = db.Column(db.Text)
number = db.Column(db.Integer)
description = db.Column(db.String)
description = db.Column(db.Text)
localtops = relationship(
"LocalTOP", backref=backref("defaulttop"),
......@@ -495,10 +495,10 @@ class TOP(DatabaseModel):
__model_name__ = "top"
id = db.Column(db.Integer, primary_key=True)
protocol_id = db.Column(db.Integer, db.ForeignKey("protocols.id"))
name = db.Column(db.String)
name = db.Column(db.Text)
number = db.Column(db.Integer)
planned = db.Column(db.Boolean)
description = db.Column(db.String)
description = db.Column(db.Text)
likes = relationship("Like", secondary="liketopassociations")
......@@ -512,7 +512,7 @@ class LocalTOP(DatabaseModel):
id = db.Column(db.Integer, primary_key=True)
protocol_id = db.Column(db.Integer, db.ForeignKey("protocols.id"))
defaulttop_id = db.Column(db.Integer, db.ForeignKey("defaulttops.id"))
description = db.Column(db.String)
description = db.Column(db.Text)
def get_parent(self):
return self.protocol
......@@ -536,8 +536,8 @@ class Document(DatabaseModel):
__model_name__ = "document"
id = db.Column(db.Integer, primary_key=True)
protocol_id = db.Column(db.Integer, db.ForeignKey("protocols.id"))
name = db.Column(db.String)
filename = db.Column(db.String)
name = db.Column(db.Text)
filename = db.Column(db.Text)
is_compiled = db.Column(db.Boolean)
is_private = db.Column(db.Boolean)
......@@ -565,8 +565,8 @@ class DecisionDocument(DatabaseModel):
__model_name__ = "decisiondocument"
id = db.Column(db.Integer, primary_key=True)
decision_id = db.Column(db.Integer, db.ForeignKey("decisions.id"))
name = db.Column(db.String)
filename = db.Column(db.String)
name = db.Column(db.Text)
filename = db.Column(db.Text)
def get_parent(self):
return self.decision
......@@ -677,8 +677,8 @@ class Todo(DatabaseModel):
id = db.Column(db.Integer, primary_key=True)
protocoltype_id = db.Column(db.Integer, db.ForeignKey("protocoltypes.id"))
number = db.Column(db.Integer)
who = db.Column(db.String)
description = db.Column(db.String)
who = db.Column(db.Text)
description = db.Column(db.Text)
state = db.Column(db.Enum(TodoState), nullable=False)
date = db.Column(db.Date, nullable=True)
......@@ -781,7 +781,7 @@ class Decision(DatabaseModel):
__model_name__ = "decision"
id = db.Column(db.Integer, primary_key=True)
protocol_id = db.Column(db.Integer, db.ForeignKey("protocols.id"))
content = db.Column(db.String)
content = db.Column(db.Text)
document = relationship(
"DecisionDocument", backref=backref("decision"),
......@@ -803,7 +803,7 @@ class DecisionCategory(DatabaseModel):
__model_name__ = "decisioncategory"
id = db.Column(db.Integer, primary_key=True)
protocoltype_id = db.Column(db.Integer, db.ForeignKey("protocoltypes.id"))
name = db.Column(db.String)
name = db.Column(db.Text)
def get_parent(self):
return self.protocoltype
......@@ -825,7 +825,7 @@ class MeetingReminder(DatabaseModel):
days_before = db.Column(db.Integer)
send_public = db.Column(db.Boolean)
send_private = db.Column(db.Boolean)
additional_text = db.Column(db.String)
additional_text = db.Column(db.Text)
def get_parent(self):
return self.protocoltype
......@@ -836,10 +836,10 @@ class Error(DatabaseModel):
__model_name__ = "error"
id = db.Column(db.Integer, primary_key=True)
protocol_id = db.Column(db.Integer, db.ForeignKey("protocols.id"))
action = db.Column(db.String)
name = db.Column(db.String)
action = db.Column(db.Text)
name = db.Column(db.Text)
datetime = db.Column(db.DateTime)
description = db.Column(db.String)
description = db.Column(db.Text)
def get_parent(self):
return self.protocol
......@@ -857,8 +857,8 @@ class TodoMail(DatabaseModel):
__tablename__ = "todomails"
__model_name__ = "todomail"
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String, unique=True)
mail = db.Column(db.String)
name = db.Column(db.String(128), unique=True)
mail = db.Column(db.Text)
def get_formatted_mail(self):
return "{} <{}>".format(self.name, self.mail)
......@@ -869,9 +869,9 @@ class OldTodo(DatabaseModel):
__model_name__ = "oldtodo"
id = db.Column(db.Integer, primary_key=True)
old_id = db.Column(db.Integer)
who = db.Column(db.String)
description = db.Column(db.String)
protocol_key = db.Column(db.String)
who = db.Column(db.Text)
description = db.Column(db.Text)
protocol_key = db.Column(db.Text)
class DefaultMeta(DatabaseModel):
......@@ -879,9 +879,9 @@ class DefaultMeta(DatabaseModel):
__model_name__ = "defaultmeta"
id = db.Column(db.Integer, primary_key=True)
protocoltype_id = db.Column(db.Integer, db.ForeignKey("protocoltypes.id"))
key = db.Column(db.String)
name = db.Column(db.String)
value =