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.

11009 questions
1569
votes
32 answers

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,889
  • 5
  • 19
  • 11
1032
votes
19 answers

How can I rollback a specific migration?

I have the migration file db\migrate\20100905201547_create_blocks.rb. How can I specifically rollback that migration file?
AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
578
votes
24 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…
470
votes
9 answers

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

I am trying to add a 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 index…
JJD
  • 50,076
  • 60
  • 203
  • 339
435
votes
6 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
  • 343,444
  • 107
  • 203
  • 205
389
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…
paddle42380
  • 6,921
  • 7
  • 32
  • 40
345
votes
19 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,532
  • 11
  • 52
  • 94
315
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,905
  • 5
  • 26
  • 22
300
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,730
  • 18
  • 53
  • 86
299
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,238
  • 4
  • 25
  • 24
255
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,535
  • 3
  • 22
  • 16
254
votes
41 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…
user0129e021939232
  • 6,205
  • 24
  • 87
  • 140
248
votes
25 answers

SQL Server String or binary data would be truncated

I am involved in a data migration project. I am getting the following error when I try to insert data from one table into another table (SQL Server 2005): Msg 8152, Level 16, State 13, Line 1 String or binary data would be truncated. The source…
Jim Evans
  • 6,285
  • 10
  • 37
  • 60
243
votes
9 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,720
  • 2
  • 23
  • 26
233
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
  • 10,351
  • 29
  • 90
  • 165
1
2 3
99 100