Remove <br/> from safe string indicating that CSRF cooking is missing.
[larjonas-mediagoblin.git] / mediagoblin / db / migrations / env.py
blob712b6164d5473af54d79987efcf993486b12c310
1 from __future__ import with_statement
2 from alembic import context
3 from sqlalchemy import engine_from_config, pool
4 from logging.config import fileConfig
6 # this is the Alembic Config object, which provides
7 # access to the values within the .ini file in use.
8 config = context.config
10 # Interpret the config file for Python logging.
11 # This line sets up loggers basically.
12 fileConfig(config.config_file_name)
14 # add your model's MetaData object here
15 # for 'autogenerate' support
16 # from myapp import mymodel
17 # target_metadata = mymodel.Base.metadata
18 target_metadata = None
20 # other values from the config, defined by the needs of env.py,
21 # can be acquired:
22 # my_important_option = config.get_main_option("my_important_option")
23 # ... etc.
25 def run_migrations_offline():
26 """Run migrations in 'offline' mode.
28 This configures the context with just a URL
29 and not an Engine, though an Engine is acceptable
30 here as well. By skipping the Engine creation
31 we don't even need a DBAPI to be available.
33 Calls to context.execute() here emit the given string to the
34 script output.
36 """
37 url = config.get_main_option("sqlalchemy.url")
38 context.configure(url=url, target_metadata=target_metadata)
40 with context.begin_transaction():
41 context.run_migrations()
43 def run_migrations_online():
44 """Run migrations in 'online' mode.
46 In this scenario we need to create an Engine
47 and associate a connection with the context.
49 """
50 engine = engine_from_config(
51 config.get_section(config.config_ini_section),
52 prefix='sqlalchemy.',
53 poolclass=pool.NullPool)
55 connection = engine.connect()
56 context.configure(
57 connection=connection,
58 target_metadata=target_metadata
61 try:
62 with context.begin_transaction():
63 context.run_migrations()
64 finally:
65 connection.close()
67 if context.is_offline_mode():
68 run_migrations_offline()
69 else:
70 run_migrations_online()