Permalink
Browse files

Stripped whitespace

  • Loading branch information...
1 parent b7b5566 commit 46def2684e60fde53d23360c7cf8b972a99a49fb @dkubb dkubb committed Sep 1, 2011
View
@@ -13,25 +13,25 @@ task :environment do
end
namespace :db do
-
+
namespace :auto do
-
+
desc "Perform auto-migration (reset your db data)"
task :migrate => :environment do |t, _|
puts "=> Auto-migrating"
::DataMapper.auto_migrate!
puts "<= #{t.name} done"
end
-
+
desc "Perform non destructive auto-migration"
task :upgrade => :environment do
puts "=> Auto-upgrading"
::DataMapper.auto_upgrade!
puts "<= #{t.name} done"
end
-
+
end
-
+
desc "Run all pending migrations, or up to specified migration"
task :migrate, [:version] => :load_migrations do |t, args|
if vers = args[:version] || ENV['VERSION']
@@ -43,13 +43,13 @@ namespace :db do
end
puts "<= #{t.name} done"
end
-
+
desc "Rollback down to specified migration, or rollback last STEP=x migrations (default 1)"
task :rollback, [:version] => :load_migrations do |t, args|
if vers = args[:version] || ENV['VERSION']
puts "=> Rolling back down to migration #{vers}"
migrate_down!(vers)
- else
+ else
step = ENV['STEP'].to_i || 1
applied = migrations.delete_if {|m| m.needs_up?}.sort # note this is N queries as currently implemented
target = applied[-1 * step] || applied[0]
@@ -67,15 +67,15 @@ namespace :db do
task :migrations => :load_migrations do
puts migrations.sort.reverse.map {|m| "#{m.position} #{m.name} #{m.needs_up? ? '' : 'APPLIED'}"}
end
-
+
task :load_migrations => :environment do
require 'dm-migrations/migration_runner'
FileList['db/migrate/*.rb'].each do |migration|
load migration
end
end
-
+
desc "Create the database"
task :create, [:repository] => :environment do |t, args|
repo = args[:repository] || ENV['REPOSITORY'] || :default
@@ -133,14 +133,12 @@ namespace :db do
seed_file = File.expand_path('db/seeds.rb', File.dirname(__FILE__))
load(seed_file) if File.exist?(seed_file)
puts "<= #{t.name} done"
- end
-
+ end
+
desc "Drop the database, migrate from scratch and initialize with the seed data"
task :reset => [:drop, :setup]
desc "Create the database, migrate and initialize with the seed data"
task :setup => [:create, :migrate, :seed]
-
-end
-
+end
@@ -33,10 +33,10 @@ module SQL #:nodoc:
# Allows for specification of the default storage engine to use when creating tables via
# migrations. Defaults to DEFAULT_ENGINE.
- #
+ #
# adapter = DataMapper.setup(:default, 'mysql://localhost/foo')
# adapter.storage_engine = 'MyISAM'
- #
+ #
# @api public
attr_accessor :storage_engine
@@ -95,7 +95,7 @@ def property_schema_statement(connection, schema)
def storage_engine
# Don't pull the default engine via show_variable for backwards compat where it was hard
# coded to InnoDB
- @storage_engine ||= DEFAULT_ENGINE
+ @storage_engine ||= DEFAULT_ENGINE
end
# @api private
@@ -25,7 +25,7 @@ def table_options(opts)
opt_engine = opts[:storage_engine] || storage_engine
opt_char_set = opts[:character_set] || character_set
opt_collation = opts[:collation] || collation
-
+
" ENGINE = #{opt_engine} CHARACTER SET #{opt_char_set} COLLATE #{opt_collation}"
end
@@ -70,34 +70,34 @@
#can't get an exact == comparison here because character set and collation may differ per connection
@creator.to_sql.should match(/^CREATE TABLE `people` \(`id` SERIAL PRIMARY KEY, `name` VARCHAR\(50\) NOT NULL, `long_string` VARCHAR\(200\)\) ENGINE = InnoDB CHARACTER SET \w+ COLLATE \w+\z/)
end
-
+
it "should allow for custom table creation options for MySQL" do
opts = {
:storage_engine => 'MyISAM',
:character_set => 'big5',
:collation => 'big5_chinese_ci',
}
-
+
creator = DataMapper::Migration::TableCreator.new(@adapter, :people, opts) do
column :id, DataMapper::Property::Serial
end
-
+
creator.to_sql.should match(/^CREATE TABLE `people` \(`id` SERIAL PRIMARY KEY\) ENGINE = MyISAM CHARACTER SET big5 COLLATE big5_chinese_ci\z/)
end
-
+
it "should respect default storage engine types specified by the MySQL adapter" do
adapter = DataMapper::Spec.adapter
adapter.extend(SQL::Mysql)
-
+
adapter.storage_engine = 'MyISAM'
-
+
creator = DataMapper::Migration::TableCreator.new(adapter, :people) do
column :id, DataMapper::Property::Serial
end
-
+
creator.to_sql.should match(/^CREATE TABLE `people` \(`id` SERIAL PRIMARY KEY\) ENGINE = MyISAM CHARACTER SET \w+ COLLATE \w+\z/)
end
-
+
when :postgres
it "should output a CREATE TABLE statement when sent #to_sql" do
@creator.to_sql.should == %q{CREATE TABLE "people" ("id" SERIAL PRIMARY KEY, "name" VARCHAR(50) NOT NULL, "long_string" VARCHAR(200))}

0 comments on commit 46def26

Please sign in to comment.