Sha256: f538735a36e38c80d4b9a98887b2ae129dc3d91bcecb02256a36f5c4b9cd4c4d

Contents?: true

Size: 608 Bytes

Versions: 3

Compression:

Stored size: 608 Bytes

Contents

# frozen_string_literal: true

require 'erb'
require 'yaml'
require 'active_record'
require 'fileutils'

config_file = File.expand_path('../../config/database.yml', __FILE__)
config = YAML.load(ERB.new(IO.read(config_file)).result)['db']

if ::File.exist?(config['database'])
  ::FileUtils.rm_f(config['database'])
end

ActiveRecord::Base.establish_connection(config)

ActiveRecord::Base.connection.create_table :users do |t|
  t.string :type
  t.string :name, null: false
  t.integer :age, null: false
  t.date :birth_date, null: false
  t.boolean :disabled, null: false, default: false

  t.timestamps
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_record-mod_sql_log_subscriber-0.2.0 bin/setup_db.rb
active_record-mod_sql_log_subscriber-0.1.2 bin/setup_db.rb
active_record-mod_sql_log_subscriber-0.1.1 bin/setup_db.rb