Implementation of “Automatic Lightweight Migration” for Core Data (iPhone)

This is what I did to make Automatic Lightweight Migration (Source: http://brainwashinc.wordpress.com/2010/01/18/iphone-coredata-automatic-light-migration/) 1. Set the Persistent Store options for automatic migration in the app delegate. Change your persistentStoreCoordinator creation to this (replace YOURDB): – (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator != nil) { return persistentStoreCoordinator; } NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @”YOURDB.sqlite”]]; // … Read more

How to implement IDbContextFactory for use with Entity Framework data migrations

I also hit this problem as i wrote my context to take a connection string name (and then used ninject to provide it). The process you’ve gone through seems correct, here is a snippet of my class implementation if it’s of any help: public class MigrationsContextFactory : IDbContextFactory<MyContext> { public MyContext Create() { return new … Read more

Is it worth using sqlalchemy-migrate ? [closed]

Use Alembic instead: http://pypi.python.org/pypi/alembic Thanks for comments, edited to add some reasoning — It’s developed by the author of SQLAlchemy, and it’s brand new and well supported. I don’t know enough about sqlalchemy-migrate to give a good comparison. But I took a quick read through the clear and concise Alembic docs, then got my own … Read more

What is the best approach to change primary keys in an existing Django app?

Agreed, your model is probably wrong. The formal primary key should always be a surrogate key. Never anything else. [Strong words. Been database designer since the 1980’s. Important lessoned learned is this: everything is changeable, even when the users swear on their mothers’ graves that the value cannot be changed is is truly a natural … Read more

How to efficiently manage frequent schema changes using sqlalchemy?

Alembic is a new database migrations tool, written by the author of SQLAlchemy. I’ve found it much easier to use than sqlalchemy-migrate. It also works seamlessly with Flask-SQLAlchemy. Auto generate the schema migration script from your SQLAlchemy models: alembic revision –autogenerate -m “description of changes” Then apply the new schema changes to your database: alembic … Read more

How (and whether) to populate rails application with initial data

Try a rake task. For example: Create the file /lib/tasks/bootstrap.rake In the file, add a task to create your default user: namespace :bootstrap do desc “Add the default user” task :default_user => :environment do User.create( :name => ‘default’, :password => ‘password’ ) end desc “Create the default comment” task :default_comment => :environment do Comment.create( :title … Read more

Completely copying a postgres table with SQL

The create table as feature in PostgreSQL may now be the answer the OP was looking for. https://www.postgresql.org/docs/9.5/static/sql-createtableas.html create table my_table_copy as select * from my_table This will create an identical table with the data. Adding with no data will copy the schema without the data. create table my_table_copy as select * from my_table with … Read more