#!/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