Sha256: 1f38545da956571601ef6318111f32ae0632d7c74f18735a6dbd1c1462d31e07
Contents?: true
Size: 753 Bytes
Versions: 2
Compression:
Stored size: 753 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 config = TinyRailsApp.config.database_configuration[Rails.env] require 'pathname' path = Pathname.new(config['database']) file = path.absolute? ? path.to_s : File.join(Rails.root, path) 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" t.timestamps end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tiny-rails-0.1.1 | templates/activerecord/migrate |
tiny-rails-0.1.0 | templates/activerecord/migrate |