Questions tagged [migration]

An action of moving between major versions of any framework, product or language, or, just as commonly, alteration to the data schema of an application. This might involve modifying existing data to make it work with the new version.

An action of moving between major versions of any framework, product or language, or, just as commonly, alteration to the data schema of an application. This might involve modifying existing data to make it work with the new version.

9601 questions
1503
votes
28 answers

Rails: How can I rename a database column in a Ruby on Rails migration?

I wrongly named a column hased_password instead of hashed_password. How do I update the database schema, using migration to rename this column?
user1994764
  • 15,229
  • 5
  • 17
  • 11
532
votes
22 answers

Rails DB Migration - How To Drop a Table?

I added a table that I thought I was going to need, but now no longer plan on using it. How should I remove that table? I've already run migrations, so the table is in my database. I figure rails generate migration should be able to handle this, but…
Jason Whitehorn
  • 12,933
  • 9
  • 51
  • 68
421
votes
9 answers

How do I handle too long index names in a Ruby on Rails ActiveRecord migration?

I am trying to add an unique index that gets created from the foreign keys of four associated tables: add_index :studies, ["user_id", "university_id", "subject_name_id", "subject_type_id"], :unique => true The database’s limitation for the…
JJD
  • 44,755
  • 49
  • 183
  • 309
419
votes
5 answers

How do you write a migration to rename an ActiveRecord model and its table in Rails?

I'm terrible at naming and realize that there are a better set of names for my models in my Rails app. Is there any way to use a migration to rename a model and its corresponding table?
readonly
  • 306,152
  • 101
  • 198
  • 201
350
votes
10 answers

Rails migration for change column

We have script/generate migration add_fieldname_to_tablename fieldname:datatype syntax for adding new columns to a model. On the same line, do we have a script/generate for changing the datatype of a column? Or should I write SQL directly into my…
papdel
  • 6,281
  • 7
  • 29
  • 38
324
votes
18 answers

Maven is not working in Java 8 when Javadoc tags are incomplete

Since I use Maven I have been able to build and install in my local repository projects that have incomplete Javadoc tags (for example, a missing parameter). However, since I migrated to Java 8 (1.8.0-ea-b90) Maven is absolutely strict about…
Sergio
  • 8,032
  • 11
  • 45
  • 87
290
votes
7 answers

Add a default value to a column through a migration

How do I add a default value to a column that already exists through a migration? All the documentation I can find shows you how to do it if the column doesn't already exist but in this case it does.
Jon
  • 3,625
  • 4
  • 24
  • 21
280
votes
11 answers

Run a single migration file

Is there an easy way to run a single migration? I don't want to migrate to a certain version I just want to run a specific one.
nan
  • 4,038
  • 4
  • 22
  • 23
280
votes
5 answers

Version of SQLite used in Android?

What is the version of SQLite used in Android? Reason: I'm wondering how to handle schema migrations. The newer SQLite versions support an "ALTER TABLE" SQL command which would save me having to copy data, drop the table, recreate table and…
Eno
  • 10,300
  • 18
  • 51
  • 83
233
votes
17 answers

Quick easy way to migrate SQLite3 to MySQL?

Anyone know a quick easy way to migrate a SQLite3 database to MySQL?
Stephen Cox
  • 3,361
  • 3
  • 19
  • 16
232
votes
5 answers

Change a column type from Date to DateTime during ROR migration

I need to change my column type from date to datetime for an app I am making. I don't care about the data as its still being developed. How can I do this?
jdog
  • 9,310
  • 19
  • 74
  • 146
227
votes
36 answers

Migration: Cannot add foreign key constraint

I'm trying to create foreign keys in Laravel however when I migrate my table using artisan i am thrown the following error: [Illuminate\Database\QueryException] SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL : alter…
001221
  • 5,535
  • 23
  • 76
  • 132
217
votes
3 answers

Backwards migration with Django South

Ok, so this seems like a really silly thing to ask, and I'm sure I'm missing something somewhere. How do you perform a backwards migration using South on Django? So I've tweaked my models, created a migration with schemamigration, run the migration…
Ruiwen
  • 2,285
  • 2
  • 16
  • 12
206
votes
8 answers

How to change a nullable column to not nullable in a Rails migration?

I created a date column in a previous migration and set it to be nullable. Now I want to change it to be not nullable. How do I go about doing this assuming there are null rows in that database? I'm ok with setting those columns to Time.now if…
Kevin Pang
  • 39,694
  • 37
  • 117
  • 169
200
votes
8 answers

Entity Framework rollback and remove bad migration

I'm using EF 6.0 for my project in C# with manual migrations and updates. I have about 5 migrations on the database, but I realised that the last migration was bad and I don't want it. I know that I can rollback to a previous migration, but when I…
Martin Brabec
  • 3,160
  • 2
  • 21
  • 25
1
2 3
99 100