data-migration

How can I send signals from within Django migrations?

ε祈祈猫儿з 提交于 2019-12-01 15:32:10
I use Django 1.7 migrations, and in particular, want to populate a newly-created database with initial data. Thus, I use a data migration for this. It looks like this: def populate_with_initial_data(apps, schema_editor): User = apps.get_model("auth", "User") new_user = User.objects.create(username="nobody") class Migration(migrations.Migration): ... operations = [ migrations.RunPython(populate_with_initial_data), ] At the same time, I want to have an instance of the UserDetails model for every new user: @receiver(signals.post_save, sender=django.contrib.auth.models.User) def add_user_details

SQL Data Transfer

有些话、适合烂在心里 提交于 2019-12-01 08:45:59
I need to transfer data from one table to the same table in another server which has been truncated. What is the easiest way to do this? Setup linked servers and then use the following on the destination database: INSERT INTO existingTable (col1,col2..) SELECT col1,col2... FROM linkedserver.dbo.database.othertable Use the SQL Server Import and Export wizard. It's probably the easiest way to accomplish this task. For more advanced data transfer, consider using bcp utility, BULK INSERT statement and OPENDATASOURCE . Back up the table on the one server, to a file, and restore that file into the

SQL Data Transfer

陌路散爱 提交于 2019-12-01 05:45:56
问题 I need to transfer data from one table to the same table in another server which has been truncated. What is the easiest way to do this? 回答1: Setup linked servers and then use the following on the destination database: INSERT INTO existingTable (col1,col2..) SELECT col1,col2... FROM linkedserver.dbo.database.othertable 回答2: Use the SQL Server Import and Export wizard. It's probably the easiest way to accomplish this task. For more advanced data transfer, consider using bcp utility, BULK

Oracle date corruption during update

冷暖自知 提交于 2019-12-01 05:21:43
I'm migrating some data from one oracle schema/table to a new schema/table on the same database. The migration script does the following: create table newtable as select ... cast(ACTIVITYDATE as date) as ACTIVITY_DATE, ... FROM oldtable where ACTIVITYDATE > sysdate - 1000; If I look at the original data, it looks fine - here's one record: select activitydate, to_char(activitydate, 'MON DD,YYYY'), to_char(activitydate, 'DD-MON-YYYY HH24:MI:SS'), dump(activitydate), length(activitydate) from orginaltable where oldpk = 1067514 Result: 18-NOV-10 NOV 18,2010 18-NOV-2010 12:59:15 Typ=12 Len=7: 120

Oracle date corruption during update

人盡茶涼 提交于 2019-12-01 03:14:53
问题 I'm migrating some data from one oracle schema/table to a new schema/table on the same database. The migration script does the following: create table newtable as select ... cast(ACTIVITYDATE as date) as ACTIVITY_DATE, ... FROM oldtable where ACTIVITYDATE > sysdate - 1000; If I look at the original data, it looks fine - here's one record: select activitydate, to_char(activitydate, 'MON DD,YYYY'), to_char(activitydate, 'DD-MON-YYYY HH24:MI:SS'), dump(activitydate), length(activitydate) from

INSERT Data From One Table Into Multiple Tables

强颜欢笑 提交于 2019-11-30 21:44:46
I'm using SQL Server 2005. I am migrating data over from a current database (single table) to a new database (normalized - many tables). In the new database, I have a base table (let's call it "BaseTable"), and multiple other tables (let's call them "DependentA" , and "DependentB" ). Some of the data from the old database will go to BaseTable, and some will go to the other two. BaseTable has a one-to-one relationship with both DependentA and DependentB, using the Id of them as the foreign key. So here's my question. How should I migrate the data over? Here is a query I've been trying, which is

Core Data Migration - Can't find mapping model for migration

杀马特。学长 韩版系。学妹 提交于 2019-11-30 09:10:21
I followed the guide found here: http://www.timisted.net/blog/archive/core-data-migration/ but keep getting "Can't find mapping model for migration" when I start up the app with the new model. I've tried it in xcode 3 and xcode 4, multiple times, but can never get it to work. Currently my options are set to: NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:NO], NSInferMappingModelAutomaticallyOption, nil]; I had YES set for the infer option before but then it was just

Migrating DATA - not just schema, Rails

会有一股神秘感。 提交于 2019-11-30 08:29:56
Sometimes, data migrations are required. As time passes, code changes and migrations using your domain model are no longer valid and migrations fail. What are the best practices for migrating data? I tried make an example to clarify the problem: Consider this. You have a migration class ChangeFromPartnerAppliedToAppliedAt < ActiveRecord::Migration def up User.all.each do |user| user.applied_at = user.partner_application_at user.save end end this runs perfectly fine, of course. Later, you need a schema change class AddAcceptanceConfirmedAt < ActiveRecord::Migration def change add_column :users,

Data migration with Hibernate

白昼怎懂夜的黑 提交于 2019-11-30 05:34:04
问题 I am working on a project for a company, where I need to migrate its previous data into a new system. Obviously both structures are totally different and I'm using hibernate for database manipulation and confused as to what would be the best approach to migrate data. Should I use hibernate, should I write stored procedures, or is there another option? Any bright ideas are welcome. 回答1: Having tried both approaches in the past, I can definitely say that this is not a scenario for which ORM was

Can Core Data handle my “system vs. user data” migration needs?

蹲街弑〆低调 提交于 2019-11-30 05:32:00
My iPhone app will have read-only "system" data AND read/write "user" data (stored either using Core Data or a custom SQLite db). The user data may reference the system data. When a new version of the app is installed (e.g., via iTunes): The new system data that comes with the update should overwrite/replace the old system data The user data should be modified to reference the new system data (where possible). Question: How is this kind of migration done with Core Data? Is it feasible? For example, let's say my application is for managing recipes. Each version of the app will come with a