FAQ Database Discussion Community


Django migrations: How to make existing model non-abstract?

django,database-migration
I have two model classes Base and Derived (inherits from Base) and Base is abstract. Now I realize Base should be concrete. How can I create migrations that do the switch for me? The main problem for me currently is the base_ptr_id column needed in the Derived table, which is...

Changing a column type from integer to string

sql,postgresql,database-migration
Using PostgreSQL, what's the command to migrate an integer column type to a string column type? Obviously I'd like to preserve the data, by converting the old integer data to strings. ...

migration rollback reverts the previous schema but previous data is lost

laravel,migration,database-migration,laravel-migrations
I have a users table having the following schema: Users - id - name - username - password This table contains 10 records and i update the schema using migration. Then I drop the column name and add two columns firstName and lastName the updated users table schema is given...

Codeignter Migration to Alter a Table

php,mysql,codeigniter,migration,database-migration
I have crated a Migration in codeigniter to create a MySQL table with 4 columns. Now I want to change the name of one of the columns without losing the data in that table. First, I have enabled migration & set the version to 1. Then, I have created a...

Migrate one column of a table to another table's column in phpmyadmin [closed]

php,mysql,phpmyadmin,database-migration
field_data_body +----------+---------------------+ | entry_id | body_value | +----------+---------------------+ | 1009 | content | +----------+---------------------+ | 1020 | | +----------+---------------------+ | 1025 | more content | +----------+---------------------+ i_posts +------+---------------+ | id | html | +------+---------------+ | 1009 | | +------+---------------+ | 1020 | | +------+---------------+ | 1025 | | +------+---------------+ i_posts...

Migrate new model fields

django,postgresql,django-models,database-migration
When I use manage.py makemigrations <app> only columns with relations are migrated to pg database. How to instruct django to migrate new basic non-relational columns, like: title = models.CharField(max_length=20, null=True) I'm using django 1.8.2. on Ubuntu...

Copying (Cloning) DB to another Vertica Cluster with Different no. of Nodes and Different IP Addresses

database,database-migration,vertica,database-cloning
I have this requirement where I have to copy the complete DB from a single node installation to a 2 nodes cluster of Vertica. As per the documentation this is not possible. Are there no workaround methods for performing this? We may not always have same no. of nodes in...

MySQL to MSSQL keep foreign key relationships

mysql,sql-server,foreign-key-relationship,database-migration
I am currently trying to migrate from an old MySQL (5.0) to MSSQL. Because I must keep the primary key relationships, I am now facing a problem. Some data inside a table begin with the id of 6102 instead of one. I can solve this by increasing the seed, which...

Laravel environment config not loading, migration fails - SQLSTATE[HY000] [2002] No such file or directory

php,laravel,laravel-4,migration,database-migration
My app/config/database.php has been setup like this: 'mysql' => array( 'driver' => 'mysql', 'host' => getenv('DB_HOST'), 'database' => getenv('DB_NAME'), 'username' => getenv('DB_USER'), 'password' => getenv('DB_PASS'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ), I have updated my env detection code like this in bootstrap/start.php: $env = $app->detectEnvironment(function() {...

Migrating local database to Azure ClearDb through mySQL Workbench

mysql,azure,database-migration
I have been trying this but no success, i get to this stage and no further.

ruby on rails 4: How to predefine fixed values in one of the columns

ruby-on-rails,fixed,database-migration,warehouse
I am trying to build a virtual warehouse. One of the columns in the database will contain a list of locations within the warehouse which is supposed to have fixed values. The warehouse is split into aisles DA to GA and each aisle is split into locations 011 to 603....

Heroku db migration error: PG::DuplicateObject: ERROR: constraint for relation already exists

ruby-on-rails,ruby,ruby-on-rails-4,heroku,database-migration
I'm trying to deploy to heroku. First, I pushed to GIT and to heroku (using git push heroku). Then I wanted to migrate the db using heroku run rake db:migrate but after migration partially got the following error message: -- add_foreign_key(:members, :organizations) (16.5ms) ALTER TABLE "members" ADD CONSTRAINT "fk_rails_43c258b686" FOREIGN...

CoreData Lightweight migrations error when integrating RestKit and MagicalRecord

ios,core-data,restkit,database-migration,magicalrecord
I am using MagicalRecord along with RestKit but I'm having trouble performing lightweight migrations. I've followed this example but got a CoreData: error: -addPersistentStoreWithType:SQLite configuration:(null) after this line is executed. Thanks,...

Generation of ROWID column in Triggers even when its Generation is switched off in SSMA v 6.0

sql-server,oracle,database-migration,sql-server-2014,sql-server-migration-assi
I used SSMA v6.0 for migrating my oracle Database to SQL Server 2014 Database. I turned off the generation of ROWID column and as expected it did not generate any additional ROWID column in any of my tables after Conversion, But Surprisingly it DID generate all the triggers associated with...

How to find out queries that run during a migration

php,laravel,database-migration,laravel-5
I have my production server on a shared host where I cannot run php artisan migrate. Is it possible that I run the migrate script on my local machine, and manually run the queries that it runs on the production server? How do I get all the queries run by...

After migrating database and mobile service the mobile service is still using old schema

azure,migration,database-migration,azure-mobile-services
I needed to move an azure project to a new account. My azure project consists of a SQL database and a mobile service connected to that database. I moved the database by backing up the database into a .bacpac file and importing it in a new Azure account. I recreated...

Laravel - onDelete(“cascade”) does not work

php,sqlite,laravel,laravel-4,database-migration
I have an Laravel 4 app with polls and different options or choices to vote. The problem is that when I destroy a poll, the options are not deleted from the database. These are my main migrations: Polls: private $table = 'polls'; public function down() { Schema::dropIfExists($this->table); } public function...

Entity FrameWork 7(beta 4) migrations error

asp.net,entity-framework,database-migration,code-first-migrations,visual-studio-2015
Who else is getting this error from the Package Manager console when he/she runs the 'Add-Migration Blah' command add-migration : The term 'add-migration' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify...

SQL DDL to support migration and updates

sql,sql-server,sql-server-2008-r2,database-migration,ddl
I have a web app that uses a basic ms-sql DB only tables and constraints nothing special. Every time i need to upgrade the schema of my DB I delete the old one and recreate a new one using a standard DDL script with a lot of create table clauses....

CDbCommand::createCommand() returns zero affected rows inside migration

sql,yii,database-migration,rows-affected,yii-migrations
This code works just fine (all database items updated as expected): foreach($idMap as $menuId=>$pageId) { $sql = "UPDATE `menus_items` SET link = '/content/show?id=".$pageId."' WHERE id = ".$menuId."; "; $affectedRows = Yii::app()->db->createCommand($sql)->execute(); echo $affectedRows." affected rows\n"; } But it prints 0 affected rows for each executed query. Why? The same effect...

EF Code First Many-to-Many with Additional Foreign Key

c#,entity-framework,database-migration
I'm using Entity Framework Code First to create a database, with two entities like this: public class Tenant { public Tenant() { Users = new HashSet<User>(); } [Key] public int ID { get; set; } [Required] [StringLength(12)] public string Code { get; set; } [Required] [StringLength(200)] public string Description {...

Ruby on Rails migrate database and data from SQLite3 to Postgres

ruby-on-rails,sqlite,postgresql,ruby-on-rails-4,database-migration
I'm trying to migrate a small SQLite database to PostgreSQL so that I can put it on Heroku. The plan is to migrate the local database to a instance of PostgreSQL. Once I know that works fine I'll migrate the database to heroku. It is proving to be extremely difficult....

Why is my Rails migration “successfully” updating but not actually changing records?

ruby-on-rails,database-migration
Well this is a first. I'm trying to run a migration for my Rails app (v4.2.0), and while the migration is succeeding, it's not actually changing anything. Specifically, I'm trying to implement a counter_cache field for a table, assigning the start value for records that already have associations. Here's my...

Casting JSON to HSTORE in Postgres 9.3+?

json,postgresql,database-migration,hstore
I've read the docs and it appears that there's no discernible way to perform an ALTER TABLE...ALTER COLUMN...USING statement to directly convert a JSON-type column to an HSTORE-type, as there's no function available that I'm aware of that will perform that CAST operation. The next best alternative I have is...

flyway-db database specific migration using java class

java,database-migration,flyway
We are having some upgrade migration that needs to be executed via a java class, some of the alter commands are database specific and we need to support both MSSQL and Oracle. Can we have database type specific java upgrade classes being loaded and executed?

How to import an Access MDB format database to MySQL (utf8_general_ci)?

mysql,sql,ms-access,database-migration
I have seen some topics about this issue but none of the free solutions works with utf8_general_ci. When we have arabic words in files we need utf8_general_ci, for example. 1 - I have tried "MySQL WorkBench" but I didn't see any option to change destination table collation, it's the default...

Oracle's OUTER JOIN (+) on string - Migration PostgreSQL

oracle,postgresql,join,database-migration,outer-join
I'm migrating a client's software database from Oracle to PostgreSQL, and I have some trouble understanding a query, what it does, and consequently how to migrate it. The query is: SELECT * FROM TBL1, TBL2, TBL3, TBL4 WHERE TBL3.Project_ID = TBL1.Project_ID AND TBL2.Type_ID = TBL1.Type_ID AND TBL4.PROPERTY_NAME(+)='Id' AND TBL4.Entity_ID(+)=TBL1.Entity_ID And...

PHP Fatal Error on 'php artisan migrate' on remote AWS EB instance: laravel.log: Permission denied

amazon-web-services,laravel-5,database-migration,artisan
When I SSH into my AWS EB instance to run php artisan migrate, I get the following error message: Link to bigger size of picture below I am completely confused. First, I don't get this error on the local server. Second, what does a simple log file have to do...

Django 1.7.1 makemigrations does not recognize an application

python,django,database-migration
I'm having the following Django apps structure: projectname backend puzzle migrations ... models database.py ... user migrations ... models database.py ... Both applications are registered in project settings file: INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'backend.puzzle', 'backend.user', ) puzzle.models.database.py contains a Django model: from django.db import models...

Is it necessary to write down() for every up() in migration in laravel?

laravel,migration,database-migration,laravel-migrations
class UpdateSessions extends Migration { public function up() { Schema::table('sessions', function($table){ $table->string('comCode')->nullable()->change(); }); } public function down() { // What should i write here? } } I have already created a sessions table writing a migration to change the column to be nullable. Now i am confused on what should...

Dotnetnuke migration from SQL 2005 to SQL 2012

sql-server-2005,sql-server-2012,dotnetnuke,database-migration
I'm trying to upgrade my DNN v6 from a SQL Server 2005 to a SQL Server 2012. My problem is, after modifying the web.config to match the new appSettings, my website automaticaly runs the install wizard. My IIS was running on a 2003 server and is now on a 2012...

PDOException (1044) SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge'

laravel,laravel-5,database-migration,laravel-migrations
I am using Laravel 5 and getting the following exception: PDOException (1044) SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge' My database configuration file is <?php return [ /* |-------------------------------------------------------------------------- | PDO Fetch Style |-------------------------------------------------------------------------- | | By default, database results will be returned as instances of the...

How to write a migrate to undo the unique constraint in Laravel?

php,laravel,laravel-4,laravel-5,database-migration
I would do this to make my email field unique in the table. $table->unique('email'); I've tried public function up() { Schema::table('contacts', function(Blueprint $table) { $table->dropUnique('email'); }); } Then, when I run php artisan migrate, I got this It tell me that it's not there, but I'm 100% sure that it's...

PostgreSQL migration and restore

postgresql,database-migration
I have a PostgreSQL v7.3 installation that I need to migrate with a minimum of fuss to a newer, resource-rich and much faster machine that already has PostgreSQL 9.1.13 installed. I have the source code to the version of v7.3 that I was using, which, if compiled and installed (easy...

Testing with rspec is causing an error: `Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development `

ruby-on-rails-3,activerecord,sqlite3,database-migration
when I run the rails server, localhost displays this error: ActiveRecord::PendingMigrationError (Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development): I have run the bin/rake... and the next error says: $ bundle exec bin/rake db:migrate RAILS_ENV=development == 20150225172130 CreateVotes: migrating ====================================== -- create_table(:votes) rake aborted! StandardError: An...

Laravel Migrations Naming Convention

php,laravel,naming-conventions,database-migration
Is there a naming convention or guide that one should follow while naming Laravel migrations or should the name only be descriptive enough ? Also, suppose you are adding 12 columns to modify a table then in such a case the migration name would be too long if made descriptive...

How to disable updating of structure.sql in rails? [duplicate]

ruby-on-rails,database-migration
This question already has an answer here: How to disable db:schema:dump for migrations 7 answers Is there a config option that would let us disable updating of the structure.sql? It constantly updates everytime we run a migration and we don't need it to update. We just need it for...

Class Not Found errors when upgrading grails to 2.5.0 for Grails database migrations files

grails,database-migration,grails-plugin
I am trying to upgrade Grails app from 2.4.3 to 2.5.0 version. Grails 2.5.0 contains fixes and improvements but doesn't have any breaking changes. Also, installed all 2.5.0 compatible plugin versions. Also gone through Grails Database Migration Plugin changelog and other plugin to support grails 2.5.0. Come across same JIRA...

Rollback one specific migration in Laravel

laravel,laravel-4,laravel-5,database-migration
I want to rollback only : Rolled back: 2015_05_15_195423_alter_table_web_directories I run php artisan migrate:rollback, 3 of my migration are rolling back. Rolled back: 2015_05_15_195423_alter_table_web_directories Rolled back: 2015_05_13_135240_create_web_directories_table Rolled back: 2015_05_13_134411_create_contacts_table I delete both of my web_directories and my contacts table unintentionally. Sadly, I never want that to happen, and if...

Switch a disk containing cloudera hadoop / hdfs / hbase data

hadoop,hbase,database-migration,cloudera,disk-partitioning
we have a Cloudera 5 installation based on one single node on a single server. Before adding 2 additional nodes on the cluster, we want to increase the size of the partition using a fresh new disk. We have the following services installed: yarn with 1 NodeManager 1 JobHistory and...

Error: The module depends on the missing object 'sysdb.ssma_oracle.db_check_init_package'

sql-server,oracle,database-migration,data-migration,sql-server-migration-assi
i migrated an entire oracle Database to SQL Server 2014 Database using SSMA. (SQL Server Migration assistant) The migration resulted in introduction of multiple Execution calls in my stored procedures (like below): The module 'INFRA_IP_WEBLOGGER$spCheckIPStatus' depends on the missing object 'sysdb.ssma_oracle.db_check_init_package'. The module will still be created; however, it cannot...

Oracle to SQL Server Migration issue - On delete cascade

sql-server,oracle,database-migration
Folks, Iam working on Oracle to MS Sql Server migraiton. One of the issue I came across is that "ON DELETE CASCADE" works fine in Oracle, but not in Sql Server. Is there any alternative to the syntax/command or is it something we need to manually remove/fix it. Could not...

Django migrations missing way to declare “needed_by”?

django,dependencies,database-migration,django-south
If you have two apps: core_app plugin_app The core does not need the optional plugin. Up to now we used south and could use needed_by if a migration of the plugin needs to run before a migration of the core app. I could not find something in the docs: https://docs.djangoproject.com/en/1.8/topics/migrations/...

Joomla database migration

joomla,content-management-system,database-migration
I have a Joomla website but I have to admit that it is a mess. I've played with files I shouldn't have been playing with. Therefore I'd like to start over with a fresh installation. But I also don't want to lose my content. Will it be enough to tell...

auto_increment in Phalcon migrations system

php,mysql,auto-increment,database-migration,phalcon
For some reason, the migration system is not behaving well with auto_increment primary keys. Am I overseeing something? (I'm using phalcon 2.0.1) I have the following auto generated migration: class LanguagesMigration_100 extends Migration { public function up() { $this->morphTable( 'languages', array( 'columns' => array( new Column( 'id', array( 'type' =>...

Laravel 5 migration error 1045

php,laravel,laravel-5,database-migration
I am having the following error: After following this guide: http://tutsnare.com/access-denied-for-user-homesteadlocalhost-laravel-5/ I changed my .env file in accordance with the guide but I'm still getting that error. Does anyone else know how to solve this? Also I am using a mac with MAMP on localhost. Thanks. ...

Alembic SQLite ALTER TABLE with self-referencing foreign key

sqlite,foreign-key-relationship,database-migration,alembic
The Alembic migration for a SQLite database: def upgrade(): with op.batch_alter_table('my_table') as batch_op: batch_op.add_column(sa.Column('parent_id', sa.String(24))) batch_op.create_foreign_key('parent_constraint', 'my_table', ['parent_id'], ['id']) which is supposed to create a foreign key parent_id referencing id of the same table my_table, creates a reference to a table called _alembic_batch_temp: CREATE TABLE "my_table" ( id VARCHAR(24) NOT...

Code based DB migration in Entity Framework 6.1.2: How to avoid using powershell commands?

c#,entity-framework,entity-framework-6,database-migration
I am using EF 6.1.2, to do Code based DB migration there are some commands we need to excecute. Which are: Add-Migration and Update-Database. I want this migration to happen in production environment. So is there any way to avoid Update-Database command in Package Manager Console and use C# APIs...

How to update already run database migration files using Grails DBMigration plugin?

grails,database-migration,liquibase
I have migration file named test-plugin-migration-1.2.groovy which nedds to be only renamed as migrations listed in it are already run and some other custom migrations. test-plugin-migration-1.2.groovy - > test-plugin-migration-1-2.groovy I tried adding a custom migration for DATABASECHANGELOG table in new file named rename-migration.groovy rename-migration.groovy changeSet(author: "Laxmi Salunkhe", id: "12345-1") {...

Migrations in production Laravel

laravel,migration,database-migration
I'm working on a personal website, and i try to find a solution to a problem and any help would be welcome. I work with Github because I'm working from several places (work, home...), and I'm wondering about migrations when I transfer my application in production. Locally, I don't have...

Can't figure out has_many/belongs_to RAILS 4

ruby-on-rails,ruby-on-rails-4,database-migration,has-many,belongs-to
My models are: class CarBrand < ActiveRecord::Base has_many :car_models end class CarModel < ActiveRecord::Base belongs_to :car_brand end and my migrations are class CreateCarBrands < ActiveRecord::Migration def up create_table :car_brands do |t| t.string "brand", :limit => 20 t.timestamps null: false end end def down drop_table :car_brands end end class CreateCarModels <...

CDbMigration::update does not work inside foreach loop

yii,sql-update,database-migration,yii-migrations
Following this question. There is something wrong, when using CDbMigration::update() inside foreach loop. This code does not work correctly: //This is executed inside Yii migration, so $this is CDbMigration. foreach($idMap as $menuId=>$pageId) { $this->update ( 'menus_items', array('link'=>'/content/show?id='.$pageId), array('id = '.$menuId) ); } For each item in $idMap value of $pageId...

Writing Migrations with Foreign Keys with in SeqelizeJS

node.js,database-migration,sequelize.js
The Background I'm building a project with SequelizeJS, a popular ORM for NodeJS. When designing a schema, there appear to be two flavors of tactic: Create model code and use the .sync() function to automatically generate tables for your models. Create model code and write manual migrations using QueryInterface and...

How to do database migration in wordpress?

database,wordpress,database-migration
I am newbie to the wordpress. I have created a custom installable plugin. Now i want that When this plugin is installed at that time some tables should be migrated to the database required by this plugin. Any help will be helpful. Thank you....