Skip to content

Commit 2cfcdc7

Browse files
committed
Inspired by all the people who try running rake db:migrate to set up the application (which causes db/schema.rb to be wiped clean!) and then try to run rake install later on. Thanks go to Dave Ekhaus for the chat earlier today.
1 parent ead74d1 commit 2cfcdc7

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

config/environment.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
require 'config/migration_hack'
12
# Be sure to restart your web server when you modify this file.
23
# Uncomment this to force production mode.
34
# ENV['RAILS_ENV'] = 'development'
4-
55
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
66

77
require File.join(File.dirname(__FILE__), 'boot')

config/migration_hack.rb

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# I love the smell of hax in the morning.
2+
if ARGV[0] == "db:migrate"
3+
4+
lines = File.readlines("config/environment.rb")
5+
lines.delete_if { |l| l == "require 'migration_hack'"}
6+
f = File.open("config/environment.rb", "w+")
7+
f.write(lines.join("\n"))
8+
f.close
9+
10+
FileUtils.rm(__FILE__)
11+
raise "If you are REALLY REALLY SURE you want to run rake db:migrate consider this first:
12+
If you have not yet run rake install (to install rBoard), running db:migrate will override db/schema.rb. This is a Bad Thing(tm).
13+
This is your first, last and ONLY warning. Running rake db:migrate again will result in the expected results.
14+
You have been warned!"
15+
16+
end

0 commit comments

Comments
 (0)