Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
columns = db.query(m.IdeaMessageColumn).all()
for column in columns:
synthesis = column.get_column_synthesis()
header_id = columns_headers.get(column.id, None)
if header_id is not None and synthesis is None:
name_en = column.name.closest_entry('en') or column.name.first_original()
name_fr = column.name.closest_entry('fr') or column.name.first_original()
subject_ls = m.LangString.create(u"Synthesis: {}".format(name_en.value), 'en')
subject_ls.add_value(u"Synthèse : {}".format(name_fr.value), 'fr')
body_ls = m.LangString.get(header_id) # don't clone, reuse the same langstring
column.create_column_synthesis(
subject=subject_ls,
body=body_ls,
creator_id=creator_id)
with context.begin_transaction():
op.drop_column('idea_message_column', 'header_id')
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,
**current_app.extensions["migrate"].configure_args
)
with context.begin_transaction():
context.run_migrations()
and associate a connection with the context.
"""
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
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
"""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.
"""
context.configure(
url=ALEMBIC_CONFIG.url.__to_string__(hide_password=False), target_metadata=target_metadata, literal_binds=True
)
with context.begin_transaction():
context.run_migrations()
def upgrade(pyramid_env):
with context.begin_transaction():
op.create_table(
'select_field',
sa.Column(
"id", sa.Integer,
sa.ForeignKey("configurable_field.id", ondelete='CASCADE', onupdate='CASCADE'),
primary_key=True),
sa.Column(
"multivalued", sa.Boolean)
)
op.create_table(
'select_field_option',
sa.Column('id', sa.Integer, primary_key=True),
sa.Column('order', sa.Float, nullable=False),
sa.Column('label_id', sa.Integer, sa.ForeignKey('langstring.id'), nullable=False, index=True),
sa.Column(
'select_field_id',
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, target_metadata=target_metadata, literal_binds=True
)
with context.begin_transaction():
context.run_migrations()
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool, create_engine
import logging
import logging.config
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Setup logging if necessary
root_logger = logging.getLogger()
if not root_logger.handlers:
logging.config.fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
#target_metadata = None
import kittystore.sa
target_metadata = kittystore.sa.model.Base.metadata
# other values from the config, defined by the needs of env.py,
# can be acquired:
def downgrade(pyramid_env):
with context.begin_transaction():
op.add_column(
'idea',
sa.Column('widget_id', sa.Integer,
sa.ForeignKey('widget.id')))
op.create_table(
'idea_view_widget',
sa.Column(
'id', sa.Integer, sa.ForeignKey(
'widget.id', ondelete='CASCADE', onupdate='CASCADE'),
primary_key=True),
sa.Column(
'main_idea_view_id', sa.Integer, sa.ForeignKey(
'idea_graph_view.id', ondelete="CASCADE",
onupdate="CASCADE"),
nullable=True))
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,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
and associate a connection with the context.
"""
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
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()