Questions tagged [database-migration]

database-migration is the process of transferring data between storage types, formats, or computer systems. Also refers to migrating the database from one vendor to another, or to upgrading the version of the database software.

is the process of transferring data between storage types, formats, or computer systems. Also refers to migrating the database from one vendor to another, or to upgrading the version of the database software.

See also:

4296 questions
85
votes
24 answers

EF migration shows empty Up() Down() methods

I have a local database that is currently in it's second version and should now go to it's third version. The code for the previous migrations was generated by another programmer so I am assuming I am doing something wrong here. In my model there…
user1841243
  • 1,663
  • 2
  • 19
  • 35
82
votes
8 answers

Laravel make model with migration

I'm creating a model on the Laravel 5 with this command: php artisan make:model Settings As it shows on the video lessons that as soon as model is created, new migration file also must be created. But, in my situtation, migration is not being…
Sarvar Nishonboyev
  • 12,262
  • 10
  • 69
  • 70
80
votes
10 answers

Add "ON DELETE CASCADE" to existing column in Laravel

I have user_id fk column in my table $table->foreign('user_id')->references('id')->on('users'); I should add on cascade delete feature to this existing column. How can I do this?
Farid Movsumov
  • 12,350
  • 8
  • 71
  • 97
65
votes
9 answers

Django 1.8 - what's the difference between migrate and makemigrations?

According to the documentation here: https://docs.djangoproject.com/en/1.8/topics/migrations/ it says: migrate, which is responsible for applying migrations, as well as unapplying and listing their status. and makemigrations, which is responsible…
SilentDev
  • 20,997
  • 28
  • 111
  • 214
60
votes
5 answers

Laravel : Migrations & Seeding for production data

My application needs a pre registered data set to work. So i need to insert them in the database when i set up the application. Laravel propose two mechanisms : Database migrations : "They allow a team to modify the database schema and stay up to…
gontard
  • 28,720
  • 11
  • 94
  • 117
56
votes
2 answers

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

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…
code-8
  • 54,650
  • 106
  • 352
  • 604
56
votes
8 answers

Why does Django make migrations for help_text and verbose_name changes?

When I change help_text or verbose_name for any of my model fields and run python manage.py makemigrations, it detects these changes and creates a new migration, say, 0002_xxxx.py. I am using PostgreSQL and I think these changes are irrelevant to my…
utapyngo
  • 6,946
  • 3
  • 44
  • 65
56
votes
6 answers

Schema Migrations Table

In my Rails 4 app I would like to collapse my migration files into one large file (similar to schema.rb) as it's time to do some housekeeping but I'm not sure on how to access the table in the database that stores migration data so that when I run a…
tommyd456
  • 10,443
  • 26
  • 89
  • 163
53
votes
3 answers

Changing column in Laravel migration causes exception: Changing columns for table requires Doctrine DBAL

I'm trying to change the max length of one of my columns in table reserves in one migration. The code looks like this: public function up() { // Schema::table('reserves', function($table){ $table->string("mobile", 11)->change(); …
Ahmad
  • 5,551
  • 8
  • 41
  • 57
53
votes
3 answers

How can one change the type of a Django model field from CharField to ForeignKey?

I need to change the type of a field in one of my Django models from CharField to ForeignKey. The fields are already populated with data, so I was wondering what is the best or right way to do this. Can I just update the field type and migrate, or…
ChrisM
  • 2,128
  • 1
  • 23
  • 41
53
votes
10 answers

No connection string named 'MyApplicationEntities' could be found in the application config file

I just install EF 4.3 and trying to upgrade my project with migration. however I am getting issues with trying to execute add-migration initial to my project via Package Manager console. It is throwing any exception now No connection string named…
Sanj
  • 3,770
  • 6
  • 26
  • 31
52
votes
1 answer

sqlalchemy : executing raw sql with parameter bindings

I'm trying to run this simple raw sql statement with parameters with SQLALchemy (within an alembic script) : from alembic import op t = {"code": "123", "description": "one two three"} op.execute("insert into field_tags (id, field_id, code,…
Max L.
  • 9,774
  • 15
  • 56
  • 86
52
votes
13 answers

Laravel's Artisan says nothing to migrate

I installed migrations with php artisan migrate:install then created a migration with the php artisan migrate:make create_teams_table command. Now I try to run them with the following command that I made according to the official documentation: php…
totymedli
  • 29,531
  • 22
  • 131
  • 165
49
votes
4 answers

Writing Migrations with Foreign Keys Using SequelizeJS

The Background I'm building a project with SequelizeJS, a popular ORM for NodeJS. When designing a schema, there appears to be two tactics: Create model code and use the .sync() function to automatically generate tables for your models. Create…
slifty
  • 13,062
  • 13
  • 71
  • 109
49
votes
6 answers

Migrate mongodb database from localhost to remote servers

I created a database on my local ubuntu machine. How can I transfer it to my remote server (ec2 Ubuntu)
Praveen Singh Yadav
  • 1,831
  • 4
  • 20
  • 31