volontariat/voluntary_classified_advertisement

View on GitHub
dummy/db/migrate/20130806125715_remove_timestamps_from_habtm_tables.voluntary_engine.rb

Summary

Maintainability
A
0 mins
Test Coverage
# This migration comes from voluntary_engine (originally 20120911093743)
class RemoveTimestampsFromHabtmTables < ActiveRecord::Migration
  TABLES = [
    :areas_projects, :areas_users, :projects_users, :users_roles
  ]
  
  def up
    # Have to remove timestamps from cause of:
    # PG::Error: ERROR:  null value in column "created_at" violates not-null constraint
    TABLES.each do |table|
      remove_column table, :created_at
      remove_column table, :updated_at
    end
  end

  def down
    TABLES.each do |table|
      add_column table, :created_at, :datetime, null: false
      add_column table, :updated_at, :datetime, null: false
    end
  end
end