w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Django South migrations directory outside django project
As it takes any module, just create a module outside your project and add it to your python path, e.g.: SOUTH_MIGRATION_MODULES = { 'blog': '<my_foreign_module>.migrations.blog', } Another way would be to monkey patch South's Migrations class, but really, you should avoid this hackery. from south.migration.base import Migrations def migrations_dir(self): return #my_ugly_hack Migrations.migrations_dir = migrations_dir

Categories : Django

heroku django south does not appear to use migrations
Make sure you have a init.py file in the migrations folder of the app you want to migrate. South will work locally, but not in production on heroku. Simply copy an init.py file from one of your apps, and put it into the migrations folder for the app you are getting the error for. Push that change to production, and then migrate.

Categories : Python

Django South - Unable to Reset App Migrations
To completely remove your migration history you need to delete every row in it's table on the database. Go to your database and erase all rows in south_migrationhistory table: delete from south_migrationhistory; or if you want to just reset the history of a specific app you can do: delete from south_migrationhistory where app_name='your_app_name'; Hope this helps!

Categories : Django

Django south circular dependency
There appears to be a real circular dependency here. You can break it quite easily, though: Move the creation of the m2m table in MyApp to a separate migration. The easiest way to do so, probably, is to copy 0001_initial.py to a new name, then remove the blocks for the m2m table (forwards and backwards!) in the original, and remove everything else in the copy. The copy should be named so that it is ordered between 0001_initial and 0002_whatever -- say, 0001_initial2.py; and it should depend on ("AnotherApp", "0001_initial") -- which, in turn, should depend on ("MyApp", "0001_initial").

Categories : Django

Django South migrations fails with column does not exist, for a column that hasn't been introduced yet
The problem was that the auto-generated 0023 migration in the forwards function had the following in it: for a in Blog.objects.all(): a.uuid = u'' + str(uuid.uuid1().hex) a.save() that calls the model based on the latest content, so author_bio was in it. To fix it then call the model from the "orm" like so: for a in orm.Blog.objects.all(): a.uuid = u'' + str(uuid.uuid1().hex) a.save()

Categories : Misc

South migrations and Mercurial
Problem 1 http://mercurial.selenic.com/wiki/TutorialConflict The only conflicts you will find are when 2 people touch the same code, and it is 100% correct for mercurial to ask you to intervene. Problem 2 You should start by reading the South docs: Part 5: Teams and Workflow Make sure that when employees merge their branches into the development/integration branch, that they move their migration to the next highest number if it needs to be run after everything else, otherwise you can run with --merge just fine. Problem 3 Before developer 2 integrates his branch, he should merge the current development version into his own, and resolve the conflicts. Only when the conflicts are resolved should he merge it back into the development branch. Alternatively, you have a "Lead Dev" who act

Categories : Python

Using aggregators (Min, Max, Avg) inside South migrations
This is kind of a worst case scenario, but one option would be to make South just exec the SQL directly for you. From their docs: https://south.readthedocs.org/en/latest/databaseapi.html#db-execute Getting the SQL query sometimes can be a pain, but you can make Django just give it to you from your Model.objects.filter().blahblah.blah statement Fair warning Messing about with a query object like this directly is bad so please don't do that in your deployed code. In this case though since .aggregate() doesn't return a QuerySet it's a bit harder to get at the actual query. With that said, to get the SQL from your query (assuming it's somewhat easy to isolate the whole thing) you can fire up a django-admin.py shell and do something like from django.db.models import Count import MyModel q

Categories : Python

South skip broken migrations
I usually make a temporary modification to the migration script that fails. Comment out or modify the parts that are not needed, run the migrations, then restore everything to the way it was before. It's not ideal, and it involves some duplication of work - you have to do the same steps both on dev machine and on the server, but it lets you preserve South support and work around the failing migration.

Categories : Python

Django South - Any way to detect if south migration needs to be done?
ok, that's my way. I have a app south_test with 3 migrations, that's the ´python manage.py migrate --list´ shows: south_test (*) 0001_initial (*) 0002_auto__add_person ( ) 0003_auto__add_field_person_age That is (not too) magic code: from south.models import MigrationHistory from south.migration import Migrations all_migrations = Migrations('south_test') applied_migrations = MigrationHistory.objects.filter(app_name='south_test') not_applied = list(set(all_migrations) - set([migration.get_migration() for migration in applied_migrations])) Now you have not_applied migrations. Maybe there are some details with ghost migrations. See the migrate command of south for details. Hope this helps!

Categories : Django

About Dependency Injection, IRepository and EF Migrations scenarios
I think code first migrations won’t update your model if you have an empty dbcontext object (I mean without dbset properties). So one way to handle this scenario where you are using the repository pattern and injecting dbcontext objet to every requested repository is: Design two dbcontext objects, one for development time (devdbcontext) and the other for production environment (proddbcontext). Devdbcontext will be designed with dbset properties, this way the migration workflow will be normal in development time; it will detect model changes and will recreate the database, etc. This object will be selected when you are in DEBUG mode (#if DEBUG) Proddbcontext will be a derived dbcontext object without dbset properties and will be selected when you are in RELEASE mode (#if RELEASE). Fo

Categories : Entity Framework

Ruby on Rails Migrations and Moving Up and Down Basics
you dont need to delete the migration file after migrate if you run a migrate to create a table without defining a down method , if you tried rake db:rollback it will revert the last migrate you did , you can see more in here Migration

Categories : Ruby On Rails

Django-south ValueError during a datamigration
There may be a mismatch between the model versions that you are using, because you imported directly: from cargobr.apps.accounts.models import UserProfile Instead, try referencing that model using orm in your migration. class Migration(DataMigration): def forwards(self, orm): for cargo in orm['cargo.Cargo'].objects.all(): profile = orm['accounts.UserProfile'].objects.get(user=cargo.customer) cargo.company = profile.company cargo.save()

Categories : Django

Django - Deploy syncdb & South
--fake option does not avoid errors while trying to create new migrations. It records that migrations have applied without actually applying them. Also, you need --ignore-ghost-migrations or --delete-ghost-migrations to achieve what you are looking for. To convert an existing project to south, you first need to convert the app Now, if you have already run --fake, to recover, you can do this: Go to ./manage.py dbshell DELETE FROM south_migrationhistory WHERE id > 0; //Note that this would delete everything in the table. If you want to remove migrations of a specific app, DELETE FROM south_migrationhistory WHERE app_name = 'blah'

Categories : Django

Django South error recovery: no such index
It turn out that SQLite doesn't create an index for one-to-one field in the first place, but South assumes it does. I suspect database type is the culprit for many other errors I encountered when using South. Solution is simple though. I go into the migration file and remove index part in both forward and backward functions. That's it.

Categories : Django

Django South Postgres Datamigration Issue
Not exactly sure why, but running ./manage.py migrate -v2 app made everything work correctly. I believe that option is supposed to run the migration and output more info on what it's running.

Categories : Django

django south migration and USE_TZ=True
If you use south, and change USE_TZ=False to USE_TZ=True, all your old migrations will likely break, and you'll get errors like: RuntimeWarning: DateTimeField received a naive datetime (XXX) while time zone support is active I have not found a way to have south track changes in settings.py. What I've done is alter the actual migration files. These each have a number and are in the migrations subdirectory. For each one that fails, add from django.utils import timezone, and modify any DateTimeField fields the same way as you did in your main code (making them time zone aware, or eliminating a specific non-timezone default date). Alternately you can try to reset your south migration history.

Categories : Django

Dynamic File Path in Django and South
I think you can get away here with Unipath. Unipath usage

Categories : Python

Django South Migration does not work the first time around
Of course its going to be like this, you have not made any intial schemamigrations. The right way would be like this: Register your django apps with south first. So something like: python manage.py schemamigration --initial <app_name>. Then you run manage.py syncdb. After this, you run migrate like so python manage.py migrate <apps>, please note that simply running migrate will just migrate all your registered apps. I tend to do this. If you change models to change the schema, then you can simply use: manage.py schemamigration --auto The problem that you are alluding to is this. Once you run syncdb, you already get a table crated, south had nothing to do with this. What you are hence doing is querying a database that has no migration control (iirc).

Categories : Python

django not running tests after adding south
Let syncdb create your test database by specifying SOUTH_TESTS_MIGRATE = False in settings.py. Quote from docs: If this is False, South’s test runner integration will make the test database be created using syncdb, rather than via migrations (the default).

Categories : Django

Stucked in a django south migration - TransactionManagement error
I am writing the answer to the problem I had as it can be useful for somebody. After some time of debugging I found that the problem was not related with django. It was an issue with the database and the virtual machine that hosts it. I restarted the database machine and the migrations are now working.

Categories : Python

django south migration with custom field not working
Aha! Turns out it was another custom field causing the problem; One that was created using a factory method. class MyOtherCustomField(models.Field): def __init__(self,*args,**kwargs): super(MyOtherCustomField,self).__init__(**kwargs) @classmethod def Factory(cls,model_field_class_name,**kwargs): try: # there is a global dictionary of potential field_classes and extra kwargs to pass to the constructor model_field_class_info = MODELFIELD_MAP[model_field_class_name.lower()] model_field_class = model_field_class_info[0] model_field_class_kwargs = model_field_class_info[1] except KeyError: msg = "unknown field type: '%s'" % model_field_class_name print "error: %s" % msg r

Categories : Django

Django, changed data model before app converted to south
Here's one idea.. read all the disclaimers here first, like which databases are supported for detecting FKs. https://docs.djangoproject.com/en/dev/ref/django-admin/#django-admin-inspectdb Update: the real answer is to use a mix of the bottom two ideas. Basically, inspectdb is a nice human readable way to figure out the difference between your model and the database. Then, I'd manually build alter table statements to match. Luckily, sqlall outputs the create statements, so most of it will be cut and paste for new fields. Make a backup of everything. Copy your models.py somewhere. Type in python manage.py inspectdb Find the model you're looking for and paste it into the original models.py Set up south. Paste the new / updated models.py back into your models.py Run schemamigration then m

Categories : Django

Entire table missing after Django South migration
Found the problem. This occurs with the rare combination of converting a unique, one-to-one Django relation to a simple foreign key relation, with no uniqueness constraints, done on a MySQL table, either MyISAM or InnoDB, because MySQL supports transactional schema alterations on neither, even when the engine does. To solve the problem, I just removed the db.alter_column commands, following the advice of a kind fellow, who finds no functional difference in the underlying schema between a OneToOne relationship and a ForeignKey relationship.

Categories : Mysql

Django/South - Possible to migrate data from SQLite to MySQL?
You can use dumpdata command to dump SQLite data: ./manage.py dumpdata app1 app2 app3 ... > dump.data Then, use loaddata command to load the dumped data to MySQL: ./manage.py loaddata dump.data

Categories : Django

Couldn't load fixtures with South in Django project
I've found workaround to my problem. Finally I've extracted load fixtures from South migration and delegated this action to Fabric. Now I have separated migration and load initial data, so everything works as I expect.

Categories : Django

Django: Using south on project with existing migration files
I usually use ./manage.py syncdb --migrate and it does not throw that kind of error. Are you sure that none of you other apps use a table with the same name? You can checkout which tables your app wants to create by opening a django shell and doing sth like: ./manage.py sql YourAppName

Categories : Django

duplicate table (identical) including primary key - using django south
Create the table using LIKE in forwards part, insert everything from old table to the new one. In backwards part just drop the new table. def forwards(self, orm): db.execute("CREATE TABLE new_table LIKE old_table") db.execute("INSERT new_table SELECT * old_table") def backwards(self, orm): db.drop_table('new_table') Hope that helps.

Categories : Python

Get Django South working on Heroku with custom user models?
I've searched for the answer in many places, but the only solution seems to generate the migrations files locally and push them to Heroku. That's something I wish I could prevent, but it is the only working option. Hopefully, this will be solves as of Django 1.7, when migrations are built into Django. Until then, I moved away from Heroku.

Categories : Django

South raises error when trying to switch model to django-mptt
As Victor suggested, setting "None" as the default when prompted was the proper course of action. However, it may also be necessary to use the rebuild() method on the model after the migration. I also posted to the django-mptt-dev Google Group, and the package author, Craig de Stigter replied with the following: If your migration imports the actual models (not the south ORM ones) and does a YourModel.objects.rebuild() at the end of the migration, it should migrate correctly. The actual value you use for the mptt fields in the meantime is irrelevant as the rebuild() will override it. I asked him to clarify whether he was saying I could specify "None" when asked by South to set a default value, and then go to a shell and use rebuild(), and he said yes. In any event, it seems to have w

Categories : Django

Django South - shouldn't it add foreign key & unique relationships to database?
When you execute a fake migrations it means the migrations are faked in the database.South assumes the migration (The migration in your 0001_initial.py file) is complete.No database changes will happen when you migrate with --fake. You received table exists error because some how the tables you are about to create exists in the database.May be the tables created while you run syncdb.

Categories : Django

Django South Error: "there is no enabled application matching 'myapp'"
migrations exist on a per-app basis. each app may or may not have its own migrations, but you need to create them for each app where you want to use them. (often all apps) ./manage.py migrate is a shortcut that runs migrations for all apps

Categories : Python

NoMigrations exception for django.contrib.x has no migrations
It can be that you have another app named as the last part of the module in this case 'comments' or you have an entry in the database table south_migrationhistory with app_name same as the module. Found answer here Google Groups

Categories : Python

Django ORM — Significant database alterations / data migrations
This case could be solved by 3 south migrations: [schema migration] create Photo table [data migration] for each Content record create a Photo record with photo and content fields properly set [schema migration] delete field photo from Content table Update: step 2 python manage.py datamigration <app_name> copy_photos_to_separate_model A new file will be created in <app_name>/migrations/####_copy_photos… Edit that file. Edit forward and backward methods. The first one is called when migrating forward, the other while migrating backwards. The first one creates separate photos out of consolidated model. The other will have to pick one of possibly many photos at that time and squeeze it back into Content model. The special orm object represents db's state at the time o

Categories : Django

Django Test - South migration reports 'no such table' but I can see said table in the db
The problem is that the code is running loaddata before the database table has been set up, hence it can't write the Site value. Normally manage.py test takes care of setting up the test databases - are you running using a different / custom test runner? If not, then try stepping through manage.py test to see what the initialisation order of your test code versus the calls to syncdb are. If you're using your own test runner, then add appropriate calls to syncdb. Make sure you pick up the South version if using South, and/or set SOUTH_TESTS_MIGRATE = False

Categories : Python

asp.net mvc migrations generates empty migrations files
This generally indicates the Entity Framework did not detect any changes in your model. For this to happen you have to ensure two things: Some class in your models folder changes, (add a field, a data annotation, etc) You must add a DbSet to you config. Do a file search on DbSet and make sure you add a line like this: public System.Data.Entity.DbSet<YourProject.Models.YourClass> YourDbSetName { get; set; }

Categories : Asp Net

EF5 Code first migrations reset migrations
You need to do this in two steps: Comment out your added tables and create an empty migration that updates the meta data to the state before those where added, by using the -ignore-changes switch (see my command reference) Readd your tables and create a migration. Now it should contain only those two new tables. Please note that whenever you mess manually with the migrations you need to be careful with the state of the metadata or you can get really nasty surprises.

Categories : Entity Framework

Maven - duplicating dependency with different types/classifiers in dependency management
Dependency management helps organizing your dependencies in a central place. In your case, that particular artifact is going to be used in different forms in different modules: Plain dependency Share the test code with the module that depends on it (test dependency) - Same for 3

Categories : Maven

Is modification of dependency, of a dependency mentioned in makefile, not recognized by make?
The problem is that medicine.o only depends on medicine.cpp, not on medicine.h. So you have to modify your rules to provide that missing dependency. It has absolutely nothing to do with "virtualness". You might also want to add the Makefile itself as a dependency, so if you change it and run make, things get re-built. To clarify, this generic rule: %.o:%.cpp g++ -c -o $@ $< means that any something.o depends on something.cpp only, and should be built with the following command: g++ -c -o something.o something.cpp i.e. $@ is the target name and $< is the first dependency. the format is target : <dependencies> command

Categories : C++

Direct dependency and transitive dependency in test scope through maven
During tests, the test output directory and main output directory are the first two things on the test classpath, respectively. Then come all of your direct and transitive dependencies of all scopes, following the rules for scopes and transitive dependencies in the link you mentioned and in the order you've declared them in the POM. Find details about each scope in "Dependency Scope" on the Maven site.

Categories : Maven

Making a requiring an explicit maven dependency on a transitive dependency
You should be able to define your DEP as an "optional" dependency, as described in the following question and linked blog post: Best strategy for dealing with optional dependencies http://axelfontaine.com/blog/optional-dependencies.html Essentially just: <dependency> <groupId>org.foo.bar</groupId> <artifactId>DEP</artifactId> <version>1.8.6-09</version> <optiona>true</optional> </dependency> Now your users will have to explicitly add this dependency when using this plugin, otherwise, they will encounter errors. There might also be some way to accomplish the same result but with more informative error messages - using Maven Enforcer Plugi

Categories : Maven



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.