File: active_record_schema.rb

package info (click to toggle)
ruby-otr-activerecord 2.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 356 kB
  • sloc: ruby: 561; sh: 133; makefile: 6
file content (19 lines) | stat: -rw-r--r-- 479 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
ActiveRecord::Base.logger = nil

module Schema
  def self.load!
    ActiveRecord::Base.connection.instance_eval do
      drop_table :categories if table_exists? :categories
      create_table :categories do |t|
        t.string :name, null: false
      end

      drop_table :widgets if table_exists? :widgets
      create_table :widgets do |t|
        t.string :name, null: false
        t.integer :category_id
      end
      add_index :widgets, :category_id
    end
  end
end