Skip to content

Not working when changing column default #3

@felixbuenemann

Description

@felixbuenemann

Hey, I tried using v0.1.4 with ActiveRecord 4.2.10, but the column default is always dumped as YAML, so it appear the default override is not working, if the default is changed.

The gem works, if the default is set when the column is created, but not when trying to change it.

I also tried various combinations of change_column_default and change_column with the same result.

Sample Migration:

class AddIdentifierToProjects < ActiveRecord::Migration
  def up
    change_table :projects do |t|
      t.string :identifier
    end
    execute "UPDATE projects SET identifier = id"
    change_table :projects do |t|
      t.change :identifier, :string, null: false, default: {
        expr: "currval('projects_id_seq')"
      }
    end
  end

  def down
    change_table :projects do |t|
      t.remove :identifier
    end
  end
end

Unfortunately this migration is impossible to do without changing the column default.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions