templates/activerecord/migrate in tiny-rails-0.0.2 vs templates/activerecord/migrate in tiny-rails-0.1.0
- old
+ new
@@ -6,23 +6,23 @@
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
+exit 0 if File.exist?(file) && !confirm_drop_db?
+
+# "Drop" database
+FileUtils.rm(file) if File.exist?(file)
+
+# Creates database
ActiveRecord::Base.establish_connection(config)
ActiveRecord::Base.connection
-
ActiveRecord::Schema.define do
create_table "posts" do |t|
t.string "title"
t.text "body"