Questions tagged [dbmigrate]

Database migration framework.

What question should have this tag?

Database migration related question using a framework.

Basic Definitions

Database migration refers to the change of schema over time. It is common for a project's schemas to evolve depends on the need. Similarly, migration can help to add or remove columns from the schema/table.

Introduction

Typically a migration has an up and down method, so you can roll back any migrations. For example in nodejs, a migration might look like this:

//20180722013000-location.ts

exports.up = (db: any) => {
    return db.createTable("Location", {
        description: "text",
        geoCode: "jsonb",
        id: {
            allowNull: false,
            autoIncrement: true,
            primaryKey: true,
            type: "int",
        },
        locationId: "int",
        name: "string",
        open: "boolean",
    });
};

exports.down = (db: any) => {
    return db.dropTable("Location");
};

This migration will handle creating a table with that scheme on up and dropTable on down.

Learn more

Rails Active Record migration

Node Migration

Sequelize cli // A simple solution for migration and even support seeding

290 questions
8
votes
1 answer

How to run db:migrate for test database in Rails 5?

I created a new rails 5 app with postgresql db and modified the database.yml file. I successfully created both development and test databases, but when running migrations only development db is updated and test db remains intact. Here's the list of…
Gerry
  • 10,337
  • 3
  • 31
  • 40
8
votes
2 answers

Rails DB Migration Error: relation already exists

I am getting an error when I try to migrate my db. I don't entirely remember how I got here, but I believe I: created new branch, scaffolded 'Requests', db:migrated, switched back to master, and merged branch created another branch, did some stuff,…
kibaekr
  • 1,319
  • 1
  • 21
  • 38
7
votes
4 answers

Release process for MongoDB changes

When its RDBMS, I used Liquibase to deploy the changes in the target database. That has support for multi-tenancy & roll back to different versions. In Mongo, I tried to find the equivalent library and found the…
iDroid
  • 1,140
  • 1
  • 13
  • 30
7
votes
3 answers

Rails 3 => Undefined method 'array' when I try to rake db:migrate

This is my first post here so go easy. I am trying to build my first app in Rails 3.2.1. I am trying to generate a scaffold for Paint using the following terminal command: rails generate scaffold Paint paint_family:string paint_hex:array…
ErikAtLarge
  • 83
  • 1
  • 7
6
votes
3 answers

Database Change Management - Setup for Initial Create Scripts, Subsequent Migration Scripts

I've got a database change management workflow in place. It's based on SQL scripts (so, it's not a managed code-based solution). The basic setup looks like this: Initial/ Generate Initial Schema.sql Generate Initial Required Data.sql …
Martin Suchanek
  • 3,006
  • 6
  • 31
  • 31
6
votes
1 answer

RoR Getting Started Guide: Rake db:migrate undefined method 'reference'

I'm following the RoR Getting Started tutorial. Having created posts, I'm now adding the second model to create comments. However, when I try rake db:migrate I get this: ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute…
Ed Fry
  • 93
  • 1
  • 6
5
votes
1 answer

ArgumentError: Write key must be initialized Rails

Hi I'm new to Rails and I'm using nitrous.io as my IDE. I just generated a model using rails generate model Micropost content:text user:references When I run bundle exec rake db:migrate I get the following error: ArgumentError: Write key must be…
5
votes
1 answer

Import data from SQL to MongoDB. All or nothing

I have the following architechture: I Import data from a SQL datbase into a mongodb. I use the importer to migrate data into the mongodb that provides the data to a website via an API. The importing can take a couple of minutes and if it fails I…
Victor Axelsson
  • 1,420
  • 1
  • 15
  • 32
5
votes
1 answer

Running rake db:migrate in Rails fails (table already exists) using mysql

I'm relatively new to developing on rails. I'm trying to migrate a newly created table using the following command: $ rake db:migrate but I constantly get an error that has something to do with the table already existing. But whenever I try run my…
Barry Michael Doyle
  • 9,333
  • 30
  • 83
  • 143
5
votes
3 answers

Migrating data with rake db:migrate does not change it

I am struggling with rails and db:migrate. I have a migration with this code class SetDefaultInstallmentsForLicenses < ActiveRecord::Migration def up License.where(code: 'LEADER').each do |leader| puts "Modifying license #{leader.id}…
Martin Macak
  • 3,507
  • 2
  • 30
  • 54
5
votes
1 answer

Using rake db:migrate inside another task leaves pending migrations

I'm new to rake and I'm trying to find my way in automating some tasks. So I wrote my first rake task and failed: namespace :app do desc "Leaves application like new" task :reset => :environment do Rake::Task['db:drop:all'].invoke …
zenw0lf
  • 1,232
  • 1
  • 13
  • 22
4
votes
2 answers

heroku rake db:migrate failing - how to diagnose/fix?

heroku rake db:migrate --trace --app app-name ! Internal server error This was working fine before. How to diagnose this? rake db:migrate works fine on my local db. There is no entry in the log. VERSION=xxx did not help either. Using rake…
B Seven
  • 44,484
  • 66
  • 240
  • 385
4
votes
2 answers

Rails: rake db:migrate *very* slow on Oracle

I'm using rails with the oracleenhanced adaptor to create a new interface for a legacy application. Database migrations work successfully, but take an incredibly long amount of time before rake finishes. The database changes happen pretty quickly…
Dave Smylie
  • 2,663
  • 3
  • 25
  • 32
4
votes
1 answer

search_path in structure.sql file gets modified by rails db:migrate

Everytime I run rake db:migrate on my project the db/structure.sql changes and I'm happy. Unfortunately the changes are not only additions to my table but also something strage in explicitly using our tenant keyword and extensions…
4
votes
1 answer

How to migrate schemas in postgresql from local server to production server?

I create a database, some tables and stored procedures on my local postgres server. Now I want to automatically migrate these things to my production server without creating everything from scratch again. This should be something quite…
1
2
3
19 20