database-migration

Django renaming App and migrations

我的梦境 提交于 2019-12-18 04:28:08
问题 I have django app named "app1" with models and migrations files. I renamed this app to "app2" and I fixed all imports, urls ... But I have a problem with migrations files and data in tables. How can I write migrations with the correct way to ensure: - New installation => create the new tables - Update old versions => create new tables, move data, remove old tables PS: there is several tables with many FK. Here is my progress, I am not sure if I am on the good way: - all old migrations removed

Push database to heroku: how to use heroku pg:push

走远了吗. 提交于 2019-12-18 02:40:13
问题 I want to push my local postgresql database to heroku, using heroku pg:push command. The command looks like this: heroku pg:push mylocaldb DATABASE --app sushi according to the heroku document: https://devcenter.heroku.com/articles/heroku-postgresql. Here is my local database info: Name: mysitedb User: bill Password: bill The DATABASE_URL environment variable in my machine is set to: postgres://bill:bill@localhost/mysitedb . My app's name is secure-gorge-4090 . I tried heroku pg:push mysitedb

Add sql table column before or after specific other column - by migrations in Laravel 4.1

ぐ巨炮叔叔 提交于 2019-12-17 23:15:18
问题 Table 'users': |id|name|address|post_code|deleted_at|created_at| and I want add column 'phone_nr' somewhere between 'id' and 'deleted_at' Is it possible by migrations in Laravel 4.1? 回答1: Yes. Create a new migration using php artisan migrate:make update_users_table . Then use the table command as follows (if you're using MySQL!): Schema::table('users', function($table) { $table->string('phone_nr')->after('id'); }); Once you've finished your migration, save it and run it using php artisan

Room database migration if only new table is added

让人想犯罪 __ 提交于 2019-12-17 22:05:17
问题 Let't assume, I have a simple Room database: @Database(entities = {User.class}, version = 1) abstract class AppDatabase extends RoomDatabase { public abstract Dao getDao(); } Now, I'm adding a new entity: Pet and bumping version to 2: @Database(entities = {User.class, Pet.class}, version = 2) abstract class AppDatabase extends RoomDatabase { public abstract Dao getDao(); } Of course, Room throws an exception: java.lang.IllegalStateException: A migration from 1 to 2 is necessary. Assuming, I

NOTICES for sequence after running migration in rails on postgresql Application

喜欢而已 提交于 2019-12-17 17:55:16
问题 When i run my migration in Rails application on postgresql i got following NOTICES NOTICE: CREATE TABLE will create implicit sequence "notification_settings_id_seq" for serial column "notification_settings.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "notification_settings_pkey" for table "notification_settings" My migration file contains 088_create_notification_settings.rb class CreateNotificationSettings < ActiveRecord::Migration def self.up create_table :notification

django.db.migrations.exceptions.InconsistentMigrationHistory

允我心安 提交于 2019-12-17 17:33:19
问题 When i run python manage.py migrate on my django project, i gets the following error Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/home/hari/project/env/local/lib/python2.7/site- packages/django/core/management/__init__.py", line 363, in execute_from_command_line utility.execute() File "/home/hari/project/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute self.fetch_command

Creating MYSQL Procedure in Laravel 4 Migrations

孤街浪徒 提交于 2019-12-17 16:19:37
问题 Is there a way to generate stored MYSQL procedures in a Laravel 4 migration? For example, here's a simple procedure generation query stored as a string (via a Heredoc) $query = <<<SQL DELIMITER $$ DROP PROCEDURE IF EXISTS test$$ CREATE PROCEDURE test() BEGIN INSERT INTO `test_table`(`name`) VALUES('test'); END$$ DELIMITER ; SQL; DB:statement(DB::RAW($query)); When Running this in a migration's up() function I get this error: 回答1: There are two major problems with your code DELIMITER is not a

How do I enable EF migrations for multiple contexts to separate databases?

谁说我不能喝 提交于 2019-12-17 02:39:12
问题 How do I enable Entity Framework 5 (version 5.0.0) migrations for multiple DB contexts in the same project, where each context corresponds to its own database? When I run Enable-Migrations in the PM console (Visual Studio 2012), there's an error because of there being multiple contexts: PM> Enable-Migrations More than one context type was found in the assembly 'DatabaseService'. To enable migrations for DatabaseService.Models.Product1DbContext, use Enable-Migrations -ContextTypeName

“Migrate” database with NHibernate

穿精又带淫゛_ 提交于 2019-12-13 18:11:57
问题 I have a program using NHibernate, recently we have made an update to the database model, we have added a table. Now we use SQLite to sync parts of the "central" database to enable a offline support in the program. It is now the problems start arising... When a user have an updated version of the program, but an old version of the database NHibernate wont work properly. So I would like to "migrate" the database to the new schema. I have testet with SchemaExport , but that clears the database

Configuring abstract base class without creating table in EF Core [duplicate]

纵饮孤独 提交于 2019-12-13 15:00:19
问题 This question already has an answer here : Entity Framework Core 2.0: How to configure abstract base class once (1 answer) Closed 11 months ago . I have added DateCreated , UserCreated , DateModified and UserModified fields to each entity by creating a BaseEntity.cs class. My requirement is to generate single table which is having all the fields of base class as columns. public class BaseEntity { public DateTime? DateCreated { get; set; } public string UserCreated { get; set; } public