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"}
This diff is collapsed.
......@@ -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 = db.Column(db.String)
key = db.Column(db.Text)
name = db.Column(db.Text)
value = db.Column(db.Text)
internal = db.Column(db.Boolean)
prior = db.Column(db.Boolean, default=False, nullable=False)
......@@ -894,8 +894,8 @@ class Meta(DatabaseModel):
__model_name__ = "meta"
id = db.Column(db.Integer, primary_key=True)
protocol_id = db.Column(db.Integer, db.ForeignKey("protocols.id"))
name = db.Column(db.String)
value = db.Column(db.String)
name = db.Column(db.Text)
value = db.Column(db.Text)
internal = db.Column(db.Boolean)
def get_parent(self):
......@@ -906,7 +906,7 @@ class Like(DatabaseModel):
__tablename__ = "likes"
__model_name__ = "like"
id = db.Column(db.Integer, primary_key=True)
who = db.Column(db.String)
who = db.Column(db.Text)
class LikeProtocolAssociation(DatabaseModel):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment