Sha256: 91e090944040a3dd162c7ac165efc5cc41f42b6bbbeccac2036cc3257074ceaa

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

#!/usr/bin/env ruby

require './boot'

def confirm_drop_db?
  print 'We are going to drop and recreate the database, are you sure you want to proceed? [Y/n] '
  answer = gets.chomp.downcase
  answer.blank? || answer =~ /^y/
end

exit 0 unless confirm_drop_db?

config = TinyRailsApp.config.database_configuration[Rails.env]

# DROP DATABASE
require 'pathname'
path = Pathname.new(config['database'])
file = path.absolute? ? path.to_s : File.join(Rails.root, path)
FileUtils.rm(file)

# CREATE DATABASE
ActiveRecord::Base.establish_connection(config)
ActiveRecord::Base.connection


ActiveRecord::Schema.define do
  create_table "posts" do |t|
    t.string "title"
    t.text   "body"
    t.timestamps
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tiny-rails-0.0.2 templates/activerecord/migrate