047_add_content_state_field.rb
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:1k
源码类别:
Ajax
开发平台:
Others
- class AddContentStateField < ActiveRecord::Migration
- class Content < ActiveRecord::Base
- include BareMigration
- end
- def self.up
- modify_tables_and_update(:add_column, Content,
- :state, :text) do |content|
- unless $schema_generator
- if content.published?
- content.state = 'Published'
- elsif content.published_at
- content.state = 'PublicationPending'
- else
- content.state = 'Draft'
- end
- end
- end
- end
- def self.down
- remove_column :contents, :state
- end
- end