2005-08-02 09:58:22 +02:00
|
|
|
require 'erb'
|
|
|
|
|
|
|
|
def create_options
|
|
|
|
if @db == 'mysql'
|
|
|
|
'ENGINE = ' + (mysql_engine rescue @mysql_engine)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def db_structure(db)
|
|
|
|
db.downcase!
|
|
|
|
@db = db
|
|
|
|
case db
|
|
|
|
when 'postgresql'
|
|
|
|
@pk = 'SERIAL PRIMARY KEY'
|
|
|
|
@datetime = 'TIMESTAMP'
|
|
|
|
when 'sqlite', 'sqlite3'
|
|
|
|
@pk = 'INTEGER PRIMARY KEY'
|
|
|
|
@datetime = 'DATETIME'
|
|
|
|
when 'mysql'
|
|
|
|
@pk = 'INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY'
|
|
|
|
@datetime = 'DATETIME'
|
|
|
|
@mysql_engine = 'InnoDB'
|
|
|
|
else
|
|
|
|
raise "Unknown db type #{db}"
|
|
|
|
end
|
|
|
|
|
|
|
|
s = ''
|
2005-08-02 10:56:09 +02:00
|
|
|
Dir[RAILS_ROOT + '/db/*.erbsql'].each do |filename|
|
2005-08-02 09:58:22 +02:00
|
|
|
s += ERB.new(File.read(filename)).result
|
|
|
|
end
|
|
|
|
s
|
|
|
|
end
|