Made migrations rollbackeable

This commit is contained in:
kikito
2015-09-10 19:14:05 +02:00
parent 480a9d6f4e
commit 52a773224d
4 changed files with 16 additions and 4 deletions

View File

@@ -1,6 +1,10 @@
class SetUsernameLimit < ActiveRecord::Migration
def change
def up
execute "ALTER TABLE users ALTER COLUMN username TYPE VARCHAR(60) USING SUBSTR(username, 1, 60)"
change_column :users, :username, :string, limit: 60
end
def down
change_column :users, :username, :string, limit: nil
end
end

View File

@@ -1,5 +1,5 @@
class RemoveCommentTitle < ActiveRecord::Migration
def change
remove_column :comments, :title
remove_column :comments, :title, :string
end
end

View File

@@ -1,6 +1,10 @@
class SetOrganizationNameLimit < ActiveRecord::Migration
def change
def up
execute "ALTER TABLE organizations ALTER COLUMN name TYPE VARCHAR(60) USING SUBSTR(name, 1, 60)"
change_column :organizations, :name, :string, limit: 60
end
def down
change_column :organizations, :name, :string, limit: nil
end
end

View File

@@ -1,6 +1,10 @@
class SetTagNameLimit < ActiveRecord::Migration
def change
def up
execute "ALTER TABLE tags ALTER COLUMN name TYPE VARCHAR(40) USING SUBSTR(name, 1, 40)"
change_column :tags, :name, :string, limit: 40
end
def down
change_column :tags, :name, :string, limit: nil
end
end