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
1
vote
1 answer

Rake db:migrate error - SQLite3

I keep getting the following error when doing the rake db:migrate command: rake aborted! An error has occurred, this and all later migrations canceled: SQLite3::SQLException: duplicate column name: email: ALTER TABLE "users" ADD "email"…
1
vote
1 answer

Error with heroku run rake db:migrate

I am trying to run the command on Heroku Heroku run rake db:migrate but I get the error: Migrating to AddNameToUsers (20130320002032) == AddNameToUsers: migrating ================================================= -- add_column(:users, :name,…
1
vote
2 answers

Can Push to Heroku But Can't Run Migration

I can push a Rails app to Heroku with ... git push heroku but when I try to migrate with ... heroku run rake db:migrate I get ... Running rake db:migrate attached to terminal... failed ! You do not have access to the app…
slabounty
  • 704
  • 11
  • 21
1
vote
1 answer

rake db:migrate syntax error (that doesn't exist)

rake db:migrate aborts because of a syntax error rake aborted! /Users/Fryed/rails/treebook/db/migrate/20121009215822_devise_create_users.rb:3: syntax error, unexpected '\n', expecting…
Ed Fry
  • 93
  • 1
  • 6
1
vote
1 answer

Rails & Pre-existing MySQL Database: Is there an easy way to integrate database structure into Active Record?

I have a pre-existing MySQL database with naming conventions far from Rails conventions. Is there any option, other than manually making each model, to get all the database information ready for Rails? Obviously scaffold won't do any good here. It…
Dan
  • 3,246
  • 1
  • 32
  • 52
1
vote
1 answer

bundle exec rake db:migrate >> ROUTING ERROR

I got a small problem. I'm new and reading through the guides on how to build a demo_app. I started with '$ rails generate scaffold User name:string email:string' After successfully generating the scaffold command; I use '$bundle exec rake…
levelone
  • 2,289
  • 3
  • 16
  • 17
0
votes
3 answers

rake db:migrate RAILS_ENV=development

Why we get an error on the command rake db:migrate Rails Error: Unable to access log file. Please ensure that /home/mahaloo/mahaloo/releases/20120329200051/log/development.log exists and is chmod 0666. The log level has been raised to WARN and the…
amarradi
  • 109
  • 3
  • 16
0
votes
1 answer

Running db:reset on Heroku results in syntax error

I have a boolean field that seems to be causing issues. When I run heroku run rake db:reset, I get this as a result: rake aborted! PGError: ERROR: syntax error at or near "(" LINE 1: ...her_email" character varying(255), "admin" boolean(255)…
jeffmueller
  • 145
  • 10
0
votes
2 answers

Declare local variable: how convert this mssql script to oracle?

declare @amount float declare @result char (20) select @amount = cost from PurchaseDoc where id = 1 if @amount > 0 set @result = 'ok' else set @result = 'empty' print @result
0
votes
1 answer

After heroku run rake db:migrate (cedar stack) - migration not happening

I'm trying to run heroku run rake db:migrate, but I get the following: Running rake db:migrate attached to terminal... up, run.7 And that's it - Migration is not happening! Although I have set up everything alright - development as sqlite3 and…
em-v
  • 417
  • 1
  • 3
  • 14
0
votes
1 answer

Why might "rake db:migrate" and "rake db:rollback" not roll back more than one migration at a time?

I'm getting some unexpected behaviour with rake db:migrate and rake db:rollback. Am hoping someone might be able to shed some light for me. I made a mess of my migrations by adding a conflicting one in, and I'm trying to migrate back to 0 so that I…
Reb
  • 649
  • 1
  • 8
  • 12
0
votes
3 answers

How do I handle auto incrementing primary keys during migration

create table foo (id auto increment primary key, name varchar(255)) I wrote a simple rails migration script which creates a new record on self.up and drops it on self.drop with delete(:id => 1). If I perform db:migrate it creates a new entry with…
priya
  • 24,861
  • 26
  • 62
  • 81
0
votes
2 answers

Cannot running 'rake db:migrate' on a cloned github repo

Since I am new to rails and have learned the very basics from books I now figured that I can learn quite a bit more from reading other peoples code and trying to make sense of it so I have signed up at github and set up everything there. Now I read…
Jason Blade
  • 373
  • 2
  • 4
  • 17
0
votes
1 answer

rake db migration issues

Some questions on db migration tasks (rake db:migrate) Does it make sense to rename the file names, if there is a spelling mistake. (e.g. CreaetFoos.rb to CreateFoos.rb) I created a migration script (say version '3') by mistake during the dev…
Jason
  • 12,229
  • 20
  • 51
  • 66
0
votes
0 answers

Upgrading PostgreSQL to 15.3 with old data

I'm running Postgres 10.4 in the docker container for [Posit Connect (https://posit.co/products/enterprise/connect/) application. The latest version of Posit Connect requires Postgres 15.3. When I updated the Postgres container image to 15.3, I got…
Beamer
  • 9
  • 2