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.

migration
Filter by
Sorted by
Tagged with
1582 votes
32 answers
629k views

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's user avatar
1043 votes
20 answers
743k views

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's user avatar
582 votes
24 answers
471k views

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 ...
Jason Whitehorn's user avatar
475 votes
9 answers
140k views

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", ...
JJD's user avatar
  • 50.6k
439 votes
7 answers
157k views

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's user avatar
  • 349k
394 votes
11 answers
370k views

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 ...
paddle42380's user avatar
  • 7,021
346 votes
19 answers
227k views

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....
Sergio's user avatar
  • 8,592
318 votes
7 answers
234k views

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's user avatar
  • 3,935
305 votes
11 answers
210k views

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's user avatar
  • 4,308
305 votes
5 answers
113k views

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 ...
Eno's user avatar
  • 10.8k
261 votes
17 answers
364k views

Quick easy way to migrate SQLite3 to MySQL? [closed]

Anyone know a quick easy way to migrate a SQLite3 database to MySQL?
Stephen Cox's user avatar
  • 3,595
257 votes
41 answers
335k views

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 ...
user0129e021939232's user avatar
256 votes
25 answers
918k views

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 ...
Jim Evans's user avatar
  • 6,385
248 votes
9 answers
514k views

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 ...
Martin Brabec's user avatar
235 votes
8 answers
162k views

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 ...
Kevin Pang's user avatar
  • 41.3k
234 votes
5 answers
169k views

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's user avatar
  • 10.5k
220 votes
3 answers
70k views

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 ...
Ruiwen's user avatar
  • 2,325
212 votes
21 answers
282k views

List all sequences in a Postgres db 8.1 with SQL

I'm converting a db from postgres to mysql. Since i cannot find a tool that does the trick itself, i'm going to convert all postgres sequences to autoincrement ids in mysql with autoincrement value. ...
apelliciari's user avatar
  • 8,361
192 votes
9 answers
115k views

rake db:schema:load vs. migrations

Very simple question here - if migrations can get slow and cumbersome as an app gets more complex and if we have the much cleaner rake db:schema:load to call instead, why do migrations exist at all? ...
sscirrus's user avatar
  • 56.1k
188 votes
35 answers
279k views

Laravel migration: unique key is too long, even if specified

I am trying to migrate a users table in Laravel. When I run my migration I get this error: [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified ...
harryg's user avatar
  • 23.7k
175 votes
17 answers
496k views

How to implement LIMIT with SQL Server? [duplicate]

I have this query with MySQL: select * from table1 LIMIT 10,20 How can I do this with SQL Server?
Bigballs's user avatar
  • 3,799
171 votes
9 answers
168k views

Populating a database in a Laravel migration file

I'm just learning Laravel, and have a working migration file creating a users table. I am trying to populate a user record as part of the migration: public function up() { Schema::create('users', ...
Adam Hopkinson's user avatar
166 votes
7 answers
148k views

Adding :default => true to boolean in existing Rails column

I've seen a few questions (namely this one) here on SO about adding a default boolean value to an existing column. So I tried the change_column suggestion but I mustn't be doing it right. I tried: $ ...
tvalent2's user avatar
  • 4,979
162 votes
10 answers
115k views

Rails 3 migrations: Adding reference column?

If I create a new rails 3 migration with (for example) rails g migration tester title:tester user:references , everything works fine...however if I add a column with something along the lines of: ...
PlankTon's user avatar
  • 12.5k
162 votes
17 answers
131k views

Dependency graph of Visual Studio projects

I'm currently migrating a big solution (~70 projects) from VS 2005 + .NET 2.0 to VS 2008 + .NET 3.5. Currently I have VS 2008 + .NET 2.0. The problem is that I need to move projects one by one to new ...
Migol's user avatar
  • 8,331
161 votes
5 answers
106k views

Rails migration: t.references with alternative name?

So I have a create_table like this for Courses at a School: create_table :courses do |t| t.string :name t.references :course t.timestamps end but I want it to reference two other courses like: ...
themirror's user avatar
  • 10.1k
156 votes
27 answers
510k views

Laravel Migrate Specific File(s) from Migrations [duplicate]

Hi read all the included documentation here in https://laravel.com/docs/5.4/migrations. Is there a way on how to migrate a certain migration file (1 migration only), cause right now every time there ...
Martney Acha's user avatar
  • 2,862
155 votes
11 answers
235k views

How can I rename column in laravel using migration?

I have columns as mentioned bellow: public function up() { Schema::create('stnk', function(Blueprint $table) { $table->increments('id'); $table->string('no_reg', 50)-&...
Ariasa's user avatar
  • 1,839
154 votes
6 answers
172k views

Rails: Adding an index after adding column

Suppose I created a table table in a Rails app. Some time later, I add a column running: rails generate migration AddUser_idColumnToTable user_id:string. Then I realize I need to add user_id as an ...
user1611830's user avatar
  • 4,799
149 votes
5 answers
71k views

Ruby on Rails: How do I add a not null constraint to an existing column using a migration?

In my Rails (3.2) app, I have a bunch of tables in my database but I forgot to add a few not null constraints. How can I write a migration which adds not null to an existing column?
David Robertson's user avatar
143 votes
27 answers
180k views

Package Manager Console Enable-Migrations CommandNotFoundException only in a specific VS project

I tried to run the command 'Enable-Migrations' in a new project and I got the message: PM> Enable-Migrations The term 'Enable-Migrations' is not recognized as the name of a cmdlet, function, ...
Eduardo Brites's user avatar
141 votes
5 answers
106k views

Migrating from JSF 1.2 to JSF 2.0

I am working with a rather large app written in JSF 1.2. JSF 1.2 is around 6 years old now. I need to upgrade to JSF 2.0. How painful will this be? I noticed that some attributes in custom tags have ...
mkoryak's user avatar
  • 57.5k
139 votes
20 answers
45k views

Mechanisms for tracking DB schema changes [closed]

What are the best methods for tracking and/or automating DB schema changes? Our team uses Subversion for version control and we've been able to automate some of our tasks this way (pushing builds up ...
pix0r's user avatar
  • 31.2k
137 votes
9 answers
130k views

How to convert SQLite SQL dump file to PostgreSQL?

For development I'm using SQLite database with production in PostgreSQL. I updated my local database with data and need to transfer a specific table to the production database. Running sqlite database ...
DevX's user avatar
  • 1,784
133 votes
7 answers
45k views

How do I migrate a model out of one django app and into a new one?

I have a django app with four models in it. I realize now that one of these models should be in a separate app. I do have south installed for migrations, but I don't think this is something it can ...
Apreche's user avatar
  • 31.1k
130 votes
4 answers
69k views

Rails has_and_belongs_to_many migration

I have two models restaurant and user that I want to perform a has_and_belongs_to_many relationship. I have already gone into the model files and added the has_and_belongs_to_many :restaurants and ...
dbslone's user avatar
  • 2,024
129 votes
5 answers
144k views

Removing a model in rails (reverse of "rails g model Title...")

rails g model Rating user_id:integer message:string value:integer How can I completely remove this model? Thanks
Colbern's user avatar
  • 1,291
128 votes
13 answers
125k views

Warning about `$HTTP_RAW_POST_DATA` being deprecated

I switched to PHP 5.6.0 and now I get the following warning everywhere: Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this ...
rr-'s user avatar
  • 14.5k
126 votes
7 answers
70k views

Rails migration for has_and_belongs_to_many join table

How do I do a script/generate migration to create a join table for a has_and_belongs_to_many relationship? The application runs on Rails 2.3.2, but I also have Rails 3.0.3 installed.
ma11hew28's user avatar
  • 124k
123 votes
13 answers
210k views

Java error: Comparison method violates its general contract

I saw many questions about this, and tried to solve the problem, but after one hour of googling and a lots of trial & error, I still can't fix it. I hope some of you catch the problem. This is ...
Lakatos Gyula's user avatar
122 votes
24 answers
111k views

Could not load file or assembly 'Microsoft.Build.Framework'(VS 2017)

When I try running the command "update-database", I get this exception: Specify the '-Verbose' flag to view the SQL statements being applied to the target database. System.IO....
Oleksii Vorochenko's user avatar
120 votes
5 answers
124k views

Assigning default value while creating migration file

rails generate migration AddRetweetsCountToTweet retweets_count:integer Ok I use above line to create migration file that automatically generates code in the generated file to add a column to a ...
kxhitiz's user avatar
  • 1,919
120 votes
9 answers
29k views

How to migrate/convert from SVN to Mercurial (hg) on windows

I'm looking for a tool to migrate a couple of SVN repositories to Mercurial, with history, labels and so on. I'm using TortoiseHg (Windows x32), so ConvertExtensions are discarded. There's some info ...
David Lay's user avatar
  • 2,955
119 votes
12 answers
116k views

Want to upgrade project from Angular v5 to Angular v6

As Angular 6 is here, I want to upgrade or move my angular 5 client application to angular 6, but I'm not getting any tutorial or anything which can guide me through. According to me I just need to ...
Abhishek Chokra's user avatar
106 votes
14 answers
40k views

Django migration error :you cannot alter to or from M2M fields, or add or remove through= on M2M fields

I'm trying to modify a M2M field to a ForeignKey field. The command validate shows me no issues and when I run syncdb : ValueError: Cannot alter field xxx into yyy they are not compatible types (you ...
loar's user avatar
  • 1,685
105 votes
2 answers
72k views

Rails Migration to make a column null => true

I had originally created a table with column as t.string "email", :default => "", :null => false The requirement has changed and now I need to allow email to be null. How can I write a ...
Pykih's user avatar
  • 2,817
105 votes
8 answers
45k views

Loading initial data with Django 1.7+ and data migrations

I recently switched from Django 1.6 to 1.7, and I began using migrations (I never used South). Before 1.7, I used to load initial data with a fixture/initial_data.json file, which was loaded with the ...
Mickaël's user avatar
  • 3,822
103 votes
9 answers
92k views

Ruby on Rails: How can I revert a migration with rake db:migrate?

After installing devise MODEL User i got this. class DeviseCreateUsers < ActiveRecord::Migration def self.up create_table(:users) do |t| t.database_authenticatable :null => false ...
cola's user avatar
  • 12.3k
103 votes
11 answers
80k views

Rake just one migration

I'm trying to run just one migration out of a whole bunch in my rails app. How can I do this? I don't want to run any of the migrations before or after it. Thanks.
Anon's user avatar
  • 5,113
101 votes
25 answers
320k views

Error: Schema validation failed with the following errors: Data path "" should NOT have additional properties(project)

After migrating application from angular 5 to 6, on running ng serve the following errors pop up. Schema validation failed with the following errors: Data path "" should NOT have additional ...
V5NEXT's user avatar
  • 1,967

1
2 3 4 5
224