Show More
@@ -0,0 +1,70 b'' | |||||
|
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 | |||
|
5 | ||||
|
6 | # this is the Alembic Config object, which provides | |||
|
7 | # access to the values within the .ini file in use. | |||
|
8 | config = context.config | |||
|
9 | ||||
|
10 | # Interpret the config file for Python logging. | |||
|
11 | # This line sets up loggers basically. | |||
|
12 | fileConfig(config.config_file_name) | |||
|
13 | ||||
|
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 | |||
|
19 | ||||
|
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. | |||
|
24 | ||||
|
25 | ||||
|
26 | def run_migrations_offline(): | |||
|
27 | """Run migrations in 'offline' mode. | |||
|
28 | ||||
|
29 | This configures the context with just a URL | |||
|
30 | and not an Engine, though an Engine is acceptable | |||
|
31 | here as well. By skipping the Engine creation | |||
|
32 | we don't even need a DBAPI to be available. | |||
|
33 | ||||
|
34 | Calls to context.execute() here emit the given string to the | |||
|
35 | script output. | |||
|
36 | ||||
|
37 | """ | |||
|
38 | url = config.get_main_option("sqlalchemy.url") | |||
|
39 | context.configure( | |||
|
40 | url=url, target_metadata=target_metadata, literal_binds=True) | |||
|
41 | ||||
|
42 | with context.begin_transaction(): | |||
|
43 | context.run_migrations() | |||
|
44 | ||||
|
45 | ||||
|
46 | def run_migrations_online(): | |||
|
47 | """Run migrations in 'online' mode. | |||
|
48 | ||||
|
49 | In this scenario we need to create an Engine | |||
|
50 | and associate a connection with the context. | |||
|
51 | ||||
|
52 | """ | |||
|
53 | connectable = engine_from_config( | |||
|
54 | config.get_section(config.config_ini_section), | |||
|
55 | prefix='sqlalchemy.', | |||
|
56 | poolclass=pool.NullPool) | |||
|
57 | ||||
|
58 | with connectable.connect() as connection: | |||
|
59 | context.configure( | |||
|
60 | connection=connection, | |||
|
61 | target_metadata=target_metadata | |||
|
62 | ) | |||
|
63 | ||||
|
64 | with context.begin_transaction(): | |||
|
65 | context.run_migrations() | |||
|
66 | ||||
|
67 | if context.is_offline_mode(): | |||
|
68 | run_migrations_offline() | |||
|
69 | else: | |||
|
70 | run_migrations_online() |
@@ -0,0 +1,24 b'' | |||||
|
1 | """${message} | |||
|
2 | ||||
|
3 | Revision ID: ${up_revision} | |||
|
4 | Revises: ${down_revision | comma,n} | |||
|
5 | Create Date: ${create_date} | |||
|
6 | ||||
|
7 | """ | |||
|
8 | ||||
|
9 | # revision identifiers, used by Alembic. | |||
|
10 | revision = ${repr(up_revision)} | |||
|
11 | down_revision = ${repr(down_revision)} | |||
|
12 | branch_labels = ${repr(branch_labels)} | |||
|
13 | depends_on = ${repr(depends_on)} | |||
|
14 | ||||
|
15 | from alembic import op | |||
|
16 | import sqlalchemy as sa | |||
|
17 | ${imports if imports else ""} | |||
|
18 | ||||
|
19 | def upgrade(): | |||
|
20 | ${upgrades if upgrades else "pass"} | |||
|
21 | ||||
|
22 | ||||
|
23 | def downgrade(): | |||
|
24 | ${downgrades if downgrades else "pass"} |
@@ -22,6 +22,18 b' Various third-party code under GPLv3-com' | |||||
22 | of Kallithea. |
|
22 | of Kallithea. | |
23 |
|
23 | |||
24 |
|
24 | |||
|
25 | Alembic | |||
|
26 | ------- | |||
|
27 | ||||
|
28 | Kallithea incorporates an [Alembic](http://alembic.zzzcomputing.com/en/latest/) | |||
|
29 | "migration environment" in `kallithea/alembic`, portions of which is: | |||
|
30 | ||||
|
31 | Copyright © 2009-2016 by Michael Bayer. | |||
|
32 | Alembic is a trademark of Michael Bayer. | |||
|
33 | ||||
|
34 | and licensed under the MIT-permissive license, which is | |||
|
35 | [included in this distribution](MIT-Permissive-License.txt). | |||
|
36 | ||||
25 |
|
37 | |||
26 | Bootstrap |
|
38 | Bootstrap | |
27 | --------- |
|
39 | --------- |
@@ -8,6 +8,7 b' include README.rst' | |||||
8 | include development.ini |
|
8 | include development.ini | |
9 | recursive-include docs * |
|
9 | recursive-include docs * | |
10 | recursive-include init.d * |
|
10 | recursive-include init.d * | |
|
11 | recursive-include kallithea/alembic * | |||
11 | include kallithea/bin/ldap_sync.conf |
|
12 | include kallithea/bin/ldap_sync.conf | |
12 | include kallithea/bin/template.ini.mako |
|
13 | include kallithea/bin/template.ini.mako | |
13 | include kallithea/config/deployment.ini_tmpl |
|
14 | include kallithea/config/deployment.ini_tmpl |
@@ -35,6 +35,7 b" callback = lambda V: ('.'.join(map(str, " | |||||
35 | is_windows = __platform__ in ['Windows'] |
|
35 | is_windows = __platform__ in ['Windows'] | |
36 |
|
36 | |||
37 | requirements = [ |
|
37 | requirements = [ | |
|
38 | "alembic>=0.8.0,<0.9", | |||
38 | "waitress==0.8.8", |
|
39 | "waitress==0.8.8", | |
39 | "webob>=1.0.8,<=1.1.1", |
|
40 | "webob>=1.0.8,<=1.1.1", | |
40 | "webtest==1.4.3", |
|
41 | "webtest==1.4.3", |
General Comments 0
You need to be logged in to leave comments.
Login now