本文整理汇总了Python中south.migration.Migrations类的典型用法代码示例。如果您正苦于以下问题:Python Migrations类的具体用法?Python Migrations怎么用?Python Migrations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Migrations类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_south_migrations
def test_south_migrations(self):
from django.core.exceptions import ImproperlyConfigured
from django.conf import settings
from django.db import models
from south.migration import Migrations, migrate_app
from south.models import MigrationHistory
from south.exceptions import NoMigrations
from south.creator import changes, actions, freezer
from south.management.commands.datamigration import Command as DataCommand
apps = [app for app in settings.INSTALLED_APPS
if app.startswith('wagtail.')]
failing_apps = []
for app_name in apps:
app = app_name.split('.')[-1]
try:
models.get_app(app)
except ImproperlyConfigured:
# This module fails to load, probably because it has no
# models.py. Ignore it and move on
continue
try:
migrations = Migrations(app, force_creation=False, verbose_creation=False)
last_migration = migrations[-1]
except (NoMigrations, IndexError):
# No migrations for this app, probably doesnt have models
continue
if migrations.app_label() not in getattr(last_migration.migration_class(), "complete_apps", []):
self.fail("Automatic migrations checking failed, since the previous migration does not have this whole app frozen.\nEither make migrations using '--freeze %s' or set 'SOUTH_AUTO_FREEZE_APP = True' in your settings.py." % migrations.app_label())
# Alright, construct two model dicts to run the differ on.
old_defs = dict(
(k, v) for k, v in last_migration.migration_class().models.items()
if k.split(".")[0] == migrations.app_label()
)
new_defs = dict(
(k, v) for k, v in freezer.freeze_apps([migrations.app_label()]).items()
if k.split(".")[0] == migrations.app_label()
)
change_source = changes.AutoChanges(
migrations = migrations,
old_defs = old_defs,
old_orm = last_migration.orm(),
new_defs = new_defs,
)
name = 'test'
# Get the actions, and then insert them into the actions lists
if list(change_source.get_changes()):
failing_apps.append(app_name)
if failing_apps:
self.fail('Model changes with no South migration detected in apps: %s' % (
', '.join(failing_apps)))
开发者ID:akrawchyk,项目名称:wagtail,代码行数:59,代码来源:test_migrations.py
示例2: handle
def handle(self, app=None, *args, **options):
# Make sure we have an app
if not app:
print("Please specify an app to convert.")
return
# See if the app exists
app = app.split(".")[-1]
try:
app_module = models.get_app(app)
except ImproperlyConfigured:
print("There is no enabled application matching '%s'." % app)
return
# Try to get its list of models
model_list = models.get_models(app_module)
if not model_list:
print("This application has no models; this command is for applications that already have models syncdb'd.")
print("Make some models, and then use ./manage.py schemamigration %s --initial instead." % app)
return
# Ask South if it thinks it's already got migrations
try:
Migrations(app)
except NoMigrations:
pass
else:
print("This application is already managed by South.")
return
# Finally! It seems we've got a candidate, so do the two-command trick
verbosity = int(options.get('verbosity', 0))
management.call_command("schemamigration", app, initial=True, verbosity=verbosity)
# Now, we need to re-clean and sanitise appcache
hacks.clear_app_cache()
hacks.repopulate_app_cache()
# And also clear our cached Migration classes
Migrations._clear_cache()
# Now, migrate
management.call_command(
"migrate",
app,
"0001",
fake=True,
verbosity=verbosity,
ignore_ghosts=options.get("ignore_ghosts", False),
delete_ghosts=options.get("delete_ghosts", False),
)
print()
print("App '%s' converted. Note that South assumed the application's models matched the database" % app)
print("(i.e. you haven't changed it since last syncdb); if you have, you should delete the %s/migrations" % app)
print("directory, revert models.py so it matches the database, and try again.")
开发者ID:takeiteasyguy,项目名称:django-project,代码行数:57,代码来源:convert_to_south.py
示例3: _south_migrate_all
def _south_migrate_all():
if not 'south' in settings.INSTALLED_APPS:
sys.stderr.write(
"warning: 'south' is not in INSTALLED_APPS, no migration done.\n")
return 0
#pylint: disable=import-error,too-many-nested-blocks
from south.migration import Migrations
from south.management.commands import migrate
schema_cmd = SchemaMigration()
initial_apps = []
auto_apps = [] #pylint: disable=unused-variable
for app in [app for app in settings.INSTALLED_APPS if app != 'south']:
try:
app_module = models.get_app(app) #pylint: disable=no-member
# South only used with Django < 1.7
clsmembers = inspect.getmembers(app_module, is_model_class)
if clsmembers:
migrations_dir = os.path.join(
os.path.dirname(app_module.__file__), 'migrations')
if os.path.isdir(migrations_dir):
schema_cmd.handle(app, auto=True)#pylint:disable=no-member
found = False
for migration_file in os.listdir(migrations_dir):
if (re.match(r'^\d\d\d\d', migration_file)
and not migration_file.startswith('0001_initial')):
found = True
break
if found:
auto_apps += [app]
else:
initial_apps += [app]
else:
schema_cmd.handle( #pylint:disable=no-member
app, initial=True)
initial_apps += [app]
else:
sys.stderr.write(
"warning: App %s does not seem to contain any Model\n" %
app)
except OSError as err:
sys.stderr.write("error: App %s, %s\n" % (app, err))
except RuntimeError as err:
sys.stderr.write("error: App %s, %s\n" % (app, err))
except ImproperlyConfigured:
sys.stderr.write(
"warning: App %s does not seem to contain a models.py\n" % app)
# Clear the cached Migrations instances now that we have more of them.
Migrations._clear_cache() #pylint: disable=no-member,protected-access
migrate_cmd = migrate.Command()
for app in initial_apps:
sys.stderr.write("initial migrate for %s\n" % app)
migrate_cmd.handle(app, fake=True)
sys.stderr.write("MIGRATE ALL!\n")
migrate_cmd.handle(no_initial_data=True)
return 0
开发者ID:djaodjin,项目名称:djaodjin-deployutils,代码行数:56,代码来源:pullapp.py
示例4: handle
def handle(self, app=None, name="", freeze_list=None, stdout=False, verbosity=1, **options):
verbosity = int(verbosity)
# Any supposed lists that are None become empty lists
freeze_list = freeze_list or []
# --stdout means name = -
if stdout:
name = "-"
# Only allow valid names
if re.search('[^_\w]', name) and name != "-":
self.error("Migration names should contain only alphanumeric characters and underscores.")
# If not name, there's an error
if not name:
self.error("You must provide a name for this migration.\n" + self.usage_str)
if not app:
self.error("You must provide an app to create a migration for.\n" + self.usage_str)
# Ensure that verbosity is not a string (Python 3)
try:
verbosity = int(verbosity)
except ValueError:
self.error("Verbosity must be an number.\n" + self.usage_str)
# Get the Migrations for this app (creating the migrations dir if needed)
migrations = Migrations(app, force_creation=True, verbose_creation=verbosity > 0)
# See what filename is next in line. We assume they use numbers.
new_filename = migrations.next_filename(name)
# Work out which apps to freeze
apps_to_freeze = self.calc_frozen_apps(migrations, freeze_list)
# So, what's in this file, then?
file_contents = self.get_migration_template() % {
"frozen_models": freezer.freeze_apps_to_string(apps_to_freeze),
"complete_apps": apps_to_freeze and "complete_apps = [%s]" % (", ".join(map(repr, apps_to_freeze))) or ""
}
# - is a special name which means 'print to stdout'
if name == "-":
print(file_contents)
# Write the migration file if the name isn't -
else:
fp = open(os.path.join(migrations.migrations_dir(), new_filename), "w")
fp.write(file_contents)
fp.close()
print("Created %s." % new_filename, file=sys.stderr)
开发者ID:brynn,项目名称:slowdown,代码行数:52,代码来源:datamigration.py
示例5: testGenerateSouthMigration
def testGenerateSouthMigration(self):
tmp = StringIO.StringIO()
sys.stdout = tmp
sys.stderr = tmp
management.call_command(
"schemamigration",
"arm_access_support",
"-",
initial=True,
)
migrations = Migrations("arm_access_support")
shutil.rmtree(migrations.migrations_dir())
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
开发者ID:armstrong,项目名称:armstrong.core.arm_access,代码行数:16,代码来源:fields.py
示例6: handle
def handle(self, app=None, name="", freeze_list=None, stdout=False, verbosity=1, **options):
# Any supposed lists that are None become empty lists
freeze_list = freeze_list or []
fixtures = options.get('fixtures', ['blogs.json'])
# --stdout means name = -
if options.get('stdout', None):
name = "-"
# Only allow valid names
if re.search('[^_\w]', name) and name != "-":
self.error("Migration names should contain only alphanumeric characters and underscores.")
# if not name, there's an error
if not name:
self.error("You must provide a name for this migration\n" + self.usage_str)
if not app:
self.error("You must provide an app to create a migration for.\n" + self.usage_str)
# Get the Migrations for this app (creating the migrations dir if needed)
migrations = Migrations(app, force_creation=True, verbose_creation=verbosity > 0)
# See what filename is next in line. We assume they use numbers.
new_filename = migrations.next_filename(name)
# Work out which apps to freeze
apps_to_freeze = self.calc_frozen_apps(migrations, freeze_list)
# So, what's in this file, then?
file_contents = MIGRATION_TEMPLATE % {
"fixutres": ",".join(fixtures),
"frozen_models": freezer.freeze_apps_to_string(apps_to_freeze),
"complete_apps": apps_to_freeze and "complete_apps = [%s]" % (", ".join(map(repr, apps_to_freeze))) or ""
}
# - is a special name which means 'print to stdout'
if name == "-":
print file_contents
# Write the migration file if the name isn't -
else:
fp = open(os.path.join(migrations.migrations_dir(), new_filename), "w")
fp.write(file_contents)
fp.close()
print >>sys.stderr, "Created %s." % new_filename
开发者ID:sebleier,项目名称:django-alpaca,代码行数:44,代码来源:fixture_migration.py
示例7: handle
def handle(self, **options):
# Resolve dependencies
Migrations.calculate_dependencies()
colors = [ 'crimson', 'darkgreen', 'darkgoldenrod', 'navy',
'brown', 'darkorange', 'aquamarine' , 'blueviolet' ]
color_index = 0
wrapper = textwrap.TextWrapper(width=40)
print("digraph G {")
# Group each app in a subgraph
for migrations in all_migrations():
print(" subgraph %s {" % migrations.app_label())
print(" node [color=%s];" % colors[color_index])
for migration in migrations:
# Munge the label - text wrap and change _ to spaces
label = "%s - %s" % (
migration.app_label(), migration.name())
label = re.sub(r"_+", " ", label)
label= "\\n".join(wrapper.wrap(label))
print(' "%s.%s" [label="%s"];' % (
migration.app_label(), migration.name(), label))
print(" }")
color_index = (color_index + 1) % len(colors)
# For every migration, print its links.
for migrations in all_migrations():
for migration in migrations:
for other in migration.dependencies:
# Added weight tends to keep migrations from the same app
# in vertical alignment
attrs = "[weight=2.0]"
# But the more interesting edges are those between apps
if other.app_label() != migration.app_label():
attrs = "[style=bold]"
print(' "%s.%s" -> "%s.%s" %s;' % (
other.app_label(), other.name(),
migration.app_label(), migration.name(),
attrs
))
print("}");
开发者ID:takeiteasyguy,项目名称:django-project,代码行数:44,代码来源:graphmigrations.py
示例8: skip_migration_if_applied
def skip_migration_if_applied(settings, app_name, table_name,
name='0001_initial'):
from south.migration import Migrations
import types
migration = Migrations(app_name)[name]
def skip_if_table_exists(original):
def wrapped(self):
# TODO: look into why we're having to return some ridiculous
# lambda
if table_exists(table_name):
return lambda x=None: None
return original()
wrapped.__name__ = original.__name__
return wrapped
migration.forwards = types.MethodType(
skip_if_table_exists(migration.forwards), migration)
开发者ID:anujsrc,项目名称:sentry,代码行数:19,代码来源:runner.py
示例9: setUp
def setUp(self):
super(MigrationTest, self).setUp()
self.before_migrations = []
for app_name, version in self.before:
migrations = Migrations(app_name)
self.before_migrations.append((app_name, migrations.guess_migration(
self._get_migration_number(version)).name()))
self.after_migrations = []
for app_name, version in self.after:
migrations = Migrations(app_name)
self.after_migrations.append((app_name, migrations.guess_migration(
self._get_migration_number(version)).name()))
self.before_orm = {}
for app_name, version in self.before_migrations:
migrations = Migrations(app_name)
self.before_orm[app_name] = migrations[version].orm()
self.after_orm = {}
for app_name, version in self.after_migrations:
migrations = Migrations(app_name)
self.after_orm[app_name] = migrations[version].orm()
for app_name, version in self.before_migrations:
# Do a fake migration first to update the migration history.
self.migrate(app_name, version=None, fake=True)
self.migrate(app_name, version=version)
开发者ID:andir,项目名称:django_migration_testcase,代码行数:27,代码来源:south_migrations.py
示例10: handle
def handle(self, **options):
# Resolve dependencies
Migrations.calculate_dependencies()
print "digraph G {"
# Print each app in a cluster
#for migrations in all_migrations():
# print " subgraph %s {" % migrations.app_label()
# # Nodes inside here are linked
# print (" -> ".join(['"%s.%s"' % (migration.app_label(), migration.name()) for migration in migrations])) + ";"
# print " }"
# For every migration, print its links.
for migrations in all_migrations():
for migration in migrations:
for other in migration.dependencies:
print '"%s.%s" -> "%s.%s"' % (
other.app_label(), other.name(),
migration.app_label(), migration.name(),
)
print "}";
开发者ID:jhelbert,项目名称:coshare,代码行数:24,代码来源:graphmigrations.py
示例11: handle
def handle(self, app=None, name="", freeze_list=None, stdout=False, verbosity=1, **options):
# Any supposed lists that are None become empty lists
freeze_list = freeze_list or []
# --stdout means name = -
if stdout:
name = "-"
# if not name, there's an error
if not name:
self.error("You must provide a name for this migration\n" + self.usage_str)
if not app:
self.error("You must provide an app to create a migration for.\n" + self.usage_str)
# Get the Migrations for this app (creating the migrations dir if needed)
try:
migrations = Migrations(app)
except NoMigrations:
Migrations.create_migrations_directory(app, verbose=verbosity > 0)
migrations = Migrations(app)
# See what filename is next in line. We assume they use numbers.
new_filename = migrations.next_filename(name)
# Work out which apps to freeze
apps_to_freeze = self.calc_frozen_apps(migrations, freeze_list)
# So, what's in this file, then?
file_contents = MIGRATION_TEMPLATE % {
"frozen_models": freezer.freeze_apps_to_string(apps_to_freeze),
"complete_apps": apps_to_freeze and "complete_apps = [%s]" % (", ".join(map(repr, apps_to_freeze))) or ""
}
# - is a special name which means 'print to stdout'
if name == "-":
print file_contents
# Write the migration file if the name isn't -
else:
fp = open(os.path.join(migrations.migrations_dir(), new_filename), "w")
fp.write(file_contents)
fp.close()
print >>sys.stderr, "Created %s." % new_filename
开发者ID:amyth,项目名称:django-south,代码行数:44,代码来源:datamigration.py
示例12: handle
def handle(self, app=None, name="", added_model_list=None, added_field_list=None, freeze_list=None, initial=False, auto=False, stdout=False, added_index_list=None, verbosity=1, **options):
# Any supposed lists that are None become empty lists
added_model_list = added_model_list or []
added_field_list = added_field_list or []
added_index_list = added_index_list or []
freeze_list = freeze_list or []
# --stdout means name = -
if stdout:
name = "-"
# Make sure options are compatable
if initial and (added_model_list or added_field_list or auto):
self.error("You cannot use --initial and other options together\n" + self.usage_str)
if auto and (added_model_list or added_field_list or initial):
self.error("You cannot use --auto and other options together\n" + self.usage_str)
# specify the default name 'initial' if a name wasn't specified and we're
# doing a migration for an entire app
if not name and initial:
name = 'initial'
# if not name, there's an error
if not name:
self.error("You must provide a name for this migration\n" + self.usage_str)
if not app:
self.error("You must provide an app to create a migration for.\n" + self.usage_str)
# Get the Migrations for this app (creating the migrations dir if needed)
migrations = Migrations(app, force_creation=True, verbose_creation=verbosity > 0)
# See what filename is next in line. We assume they use numbers.
new_filename = migrations.next_filename(name)
# What actions do we need to do?
if auto:
# Get the old migration
try:
last_migration = migrations[-1]
except IndexError:
self.error("You cannot use --auto on an app with no migrations. Try --initial.")
# Make sure it has stored models
if migrations.app_label() not in getattr(last_migration.migration_class(), "complete_apps", []):
self.error("You cannot use automatic detection, since the previous migration does not have this whole app frozen.\nEither make migrations using '--freeze %s' or set 'SOUTH_AUTO_FREEZE_APP = True' in your settings.py." % migrations.app_label())
# Alright, construct two model dicts to run the differ on.
old_defs = dict(
(k, v) for k, v in last_migration.migration_class().models.items()
if k.split(".")[0] == migrations.app_label()
)
new_defs = dict(
(k, v) for k, v in freezer.freeze_apps([migrations.app_label()]).items()
if k.split(".")[0] == migrations.app_label()
)
change_source = changes.AutoChanges(
migrations = migrations,
old_defs = old_defs,
old_orm = last_migration.orm(),
new_defs = new_defs,
)
elif initial:
# Do an initial migration
change_source = changes.InitialChanges(migrations)
else:
# Read the commands manually off of the arguments
if (added_model_list or added_field_list or added_index_list):
change_source = changes.ManualChanges(
migrations,
added_model_list,
added_field_list,
added_index_list,
)
else:
print >>sys.stderr, "You have not passed any of --initial, --auto, --add-model, --add-field or --add-index."
sys.exit(1)
# Get the actions, and then insert them into the actions lists
forwards_actions = []
backwards_actions = []
for action_name, params in change_source.get_changes():
# Run the correct Action class
try:
action_class = getattr(actions, action_name)
except AttributeError:
raise ValueError("Invalid action name from source: %s" % action_name)
else:
action = action_class(**params)
action.add_forwards(forwards_actions)
action.add_backwards(backwards_actions)
print >>sys.stderr, action.console_line()
# Nowt happen? That's not good for --auto.
if auto and not forwards_actions:
self.error("Nothing seems to have changed.")
# Work out which apps to freeze
#.........这里部分代码省略.........
开发者ID:stevejalim,项目名称:djeeknights,代码行数:101,代码来源:schemamigration.py
示例13: handle
def handle(self, app=None, name="", added_model_list=None,
added_field_list=None, freeze_list=None, initial=False,
auto=False, stdout=False, added_index_list=None, verbosity=1,
empty=False, update=False, **options):
# Any supposed lists that are None become empty lists
added_model_list = added_model_list or []
added_field_list = added_field_list or []
added_index_list = added_index_list or []
freeze_list = freeze_list or []
# --stdout means name = -
if stdout:
name = "-"
# Only allow valid names
if re.search('[^_\w]', name) and name != "-":
self.error(
"Migration names should contain only alphanumeric characters and underscores.")
# Make sure options are compatable
if initial and (added_model_list or added_field_list or auto):
self.error(
"You cannot use --initial and other options together\n" + self.usage_str)
if auto and (added_model_list or added_field_list or initial):
self.error(
"You cannot use --auto and other options together\n" + self.usage_str)
if not app:
self.error(
"You must provide an app to create a migration for.\n" + self.usage_str)
# See if the app exists
app = app.split(".")[-1]
try:
app_module = models.get_app(app)
except ImproperlyConfigured:
print("There is no enabled application matching '%s'." % app)
return
# Get the Migrations for this app (creating the migrations dir if needed)
migrations = Migrations(app, force_creation=True,
verbose_creation=int(verbosity) > 0)
# What actions do we need to do?
if auto:
# Get the old migration
try:
last_migration = migrations[-2 if update else -1]
except IndexError:
self.error(
"You cannot use --auto on an app with no migrations. Try --initial.")
# Make sure it has stored models
if migrations.app_label() not in getattr(
last_migration.migration_class(), "complete_apps", []):
self.error(
"You cannot use automatic detection, since the previous migration does not have this whole app frozen.\nEither make migrations using '--freeze %s' or set 'SOUTH_AUTO_FREEZE_APP = True' in your settings.py." % migrations.app_label())
# Alright, construct two model dicts to run the differ on.
old_defs = dict(
(k, v) for k, v in
last_migration.migration_class().models.items()
if k.split(".")[0] == migrations.app_label()
)
new_defs = dict(
(k, v) for k, v in
freezer.freeze_apps([migrations.app_label()]).items()
if k.split(".")[0] == migrations.app_label()
)
change_source = changes.AutoChanges(
migrations=migrations,
old_defs=old_defs,
old_orm=last_migration.orm(),
new_defs=new_defs,
)
elif initial:
# Do an initial migration
change_source = changes.InitialChanges(migrations)
else:
# Read the commands manually off of the arguments
if (added_model_list or added_field_list or added_index_list):
change_source = changes.ManualChanges(
migrations,
added_model_list,
added_field_list,
added_index_list,
)
elif empty:
change_source = None
else:
print(
"You have not passed any of --initial, --auto, --empty, --add-model, --add-field or --add-index.",
file=sys.stderr)
sys.exit(1)
# Validate this so we can access the last migration without worrying
if update and not migrations:
self.error("You cannot use --update on an app with no migrations.")
#.........这里部分代码省略.........
开发者ID:repodevs,项目名称:bluebottle,代码行数:101,代码来源:bb_schemamigration.py
示例14: handle
def handle(self, app=None, name="", freeze_list=None, stdout=False,
verbosity=1, **options):
# Any supposed lists that are None become empty lists
freeze_list = freeze_list or []
# --stdout means name = -
if stdout:
name = "-"
# Only allow valid names
if re.search('[^_\w]', name) and name != "-":
self.error(
"Migration names should contain only alphanumeric characters and underscores.")
# if not name, there's an error
if not name:
self.error(
"You must provide a name for this migration\n" + self.usage_str)
if not app:
self.error(
"You must provide an app to create a migration for.\n" + self.usage_str)
# Get the Migrations for this app (creating the migrations dir if needed)
migrations = Migrations(app, force_creation=True,
verbose_creation=verbosity > 0)
# See what filename is next in line. We assume they use numbers.
new_filename = migrations.next_filename(name)
# Work out which apps to freeze
apps_to_freeze = self.calc_frozen_apps(migrations, freeze_list)
# So, what's in this file, then?
file_contents = MIGRATION_TEMPLATE % {
"frozen_models": freezer.freeze_apps_to_string(apps_to_freeze),
"complete_apps": apps_to_freeze and "complete_apps = [%s]" % (
", ".join(map(repr, apps_to_freeze))) or ""
}
# Custom Bluebottle
# We find and replace the base apps with our mapped models
for model in MODEL_MAP:
model_map = MODEL_MAP[model]
mapping = {
'u"orm[\'{0}\']"'.format(model_map[
'model']): '"orm[\'{0}\']".format(MODEL_MAP[\'{1}\'][\'model\'])'.format(
'{0}', model),
'u\'{0}\''.format(
model_map['table']): 'MODEL_MAP[\'{0}\'][\'table\']'.format(
model),
'u\'{0}\''.format(model_map[
'model_lower']): 'MODEL_MAP[\'{0}\'][\'model_lower\']'.format(
model),
'u\'{0}\''.format(
model_map['app']): 'MODEL_MAP[\'{0}\'][\'app\']'.format(
model),
'[\'{0}\']'.format(
model_map['app']): '[MODEL_MAP[\'{0}\'][\'app\']]'.format(
model),
'to=orm[\'{0}\']'.format(model_map[
'model']): 'to=orm[MODEL_MAP[\'{0}\'][\'model\']]'.format(
model),
'\'object_name\': \'{0}\''.format(model_map[
'class']): '\'object_name\': MODEL_MAP[\'{0}\'][\'class\']'.format(
model)
}
file_contents = reduce(lambda x, y: x.replace(y, mapping[y]),
mapping, file_contents)
# End Custom Bluebottle
# - is a special name which means 'print to stdout'
if name == "-":
print(file_contents)
# Write the migration file if the name isn't -
else:
fp = open(os.path.join(migrations.migrations_dir(), new_filename),
"w")
fp.write(file_contents)
fp.close()
print("Created %s." % new_filename, file=sys.stderr)
开发者ID:repodevs,项目名称:bluebottle,代码行数:83,代码来源:bb_datamigration.py
示例15: print
else:
schema_cmd.handle( #pylint:disable=no-member
app, initial=True)
initial_apps += [app]
else:
print("warning: App %s does not seem to contain any Model" %
app)
except OSError, err:
print "error: App %s, %s" % (app, err)
except RuntimeError, err:
print "warning: App %s, %s" % (app, err)
except ImproperlyConfigured:
print "warning: App %s does not seem to contain a models.py" % app
# Clear the cached Migrations instances now that we have more of them.
Migrations._clear_cache() #pylint: disable=no-member,protected-access
migrate_cmd = migrate.Command()
for app in initial_apps:
print "initial migrate for %s" % app
migrate_cmd.handle(app, fake=True)
print "MIGRATE ALL!"
migrate_cmd.handle(no_initial_data=True)
return 0
def migrate_all():
"""
Create schema migrations for all apps specified in INSTALLED_APPS,
then run a migrate command.
"""
if 'south' in settings.INSTALLED_APPS:
开发者ID:Tangugo,项目名称:djaodjin-deployutils,代码行数:31,代码来源:pullapp.py
注:本文中的south.migration.Migrations类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论