Sha256: 964252ae6b1701ad3fdf083b551883e05fd48349b6c064901b0ed79124adb37e

Contents?: true

Size: 1019 Bytes

Versions: 4

Compression:

Stored size: 1019 Bytes

Contents

class CreateEditableBlocks < ActiveRecord::Migration[5.2]
  def up
    unless EditableBlock.table_exists?
      create_table :editable_blocks do |t|
        t.timestamps
        t.references :language, foreign_key: { on_update: :cascade, on_delete: :cascade }
        t.boolean :visible, default: true, null: false
        t.boolean :raw_output, default: false, null: false
        t.string :slug, null: false
        t.string :name
        t.string :description
        t.string :image
        t.string :title
        t.text :lead
        t.text :body
        t.text :footer
      end

      add_default_blocks
    end
  end

  def down
    if EditableBlock.table_exists?
      drop_table :editable_blocks
    end
  end

  private

  def add_default_blocks
    EditableBlock.create(
      slug: 'counters',
      name: 'Счётчики для сайта',
      description: 'Используется только основной текст, всегда «как есть»',
      raw_output: true
    )
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
biovision-base-0.22.180920.0 db/migrate/20180627190000_create_editable_blocks.rb
biovision-base-0.21.180812.0 db/migrate/20180627190000_create_editable_blocks.rb
biovision-base-0.20.180731.0 db/migrate/20180627190000_create_editable_blocks.rb
biovision-base-0.19.180703.1 db/migrate/20180627190000_create_editable_blocks.rb