sequel_plus 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/tasks/databases.rake +12 -12
  2. metadata +1 -1
@@ -1,10 +1,10 @@
1
1
  namespace :db do
2
- task :app_root do
3
- APP_ROOT = File.dirname File.expand_path Rake.application.rakefile
2
+ task :SEQUEL_PLUS_APP_ROOT do
3
+ SEQUEL_PLUS_APP_ROOT = File.dirname File.expand_path Rake.application.rakefile
4
4
  Rake::Task["environment"].invoke if Rake::Task.task_defined?("environment")
5
5
  end
6
6
 
7
- task :load_config => [:app_root] do
7
+ task :load_config => [:SEQUEL_PLUS_APP_ROOT] do
8
8
  raise "no DB has been defined.\n Assign DB in your Rakefile or declare an :environment task and connect to your database." unless defined? DB
9
9
  Sequel.extension :migration
10
10
  Sequel.extension :schema_dumper
@@ -62,24 +62,24 @@ namespace :db do
62
62
 
63
63
  namespace :schema do
64
64
  task :ensure_db_dir do
65
- FileUtils.mkdir_p File.join(APP_ROOT, 'db', 'migrate')
65
+ FileUtils.mkdir_p File.join(SEQUEL_PLUS_APP_ROOT, 'db', 'migrate')
66
66
  end
67
67
 
68
68
  desc "Dumps the schema to db/schema.db"
69
69
  task :dump => [:load_config, :ensure_db_dir] do
70
70
  schema = DB.dump_schema_migration
71
- schema_file = File.open(File.join(APP_ROOT, 'db', 'schema.rb'), "w"){|f| f.write(schema)}
71
+ schema_file = File.open(File.join(SEQUEL_PLUS_APP_ROOT, 'db', 'schema.rb'), "w"){|f| f.write(schema)}
72
72
  end
73
73
 
74
74
  desc "drops the schema, using schema.rb"
75
75
  task :drop => [:load_config, :dump] do
76
- eval(File.read(File.join(APP_ROOT, 'db', 'schema.rb'))).apply(DB, :down)
76
+ eval(File.read(File.join(SEQUEL_PLUS_APP_ROOT, 'db', 'schema.rb'))).apply(DB, :down)
77
77
  end
78
78
 
79
79
  desc "loads the schema from db/schema.rb"
80
80
  task :load => :load_config do
81
- eval(File.read(File.join(APP_ROOT, 'db', 'schema.rb'))).apply(DB, :up)
82
- latest_version = Sequel::Migrator.latest_migration_version(File.join(APP_ROOT, 'db', 'migrate'))
81
+ eval(File.read(File.join(SEQUEL_PLUS_APP_ROOT, 'db', 'schema.rb'))).apply(DB, :up)
82
+ latest_version = Sequel::Migrator.latest_migration_version(File.join(SEQUEL_PLUS_APP_ROOT, 'db', 'migrate'))
83
83
  Sequel::Migrator.set_current_migration_version(DB, latest_version)
84
84
  puts "Database schema loaded version #{latest_version}"
85
85
  end
@@ -92,7 +92,7 @@ namespace :db do
92
92
 
93
93
  desc "Migrate the database through scripts in db/migrate and update db/schema.rb by invoking db:schema:dump."
94
94
  task :migrate => :load_config do
95
- Sequel::Migrator.apply(DB, File.join(APP_ROOT, 'db', 'migrate'))
95
+ Sequel::Migrator.apply(DB, File.join(SEQUEL_PLUS_APP_ROOT, 'db', 'migrate'))
96
96
  Rake::Task["db:schema:dump"].invoke
97
97
  Rake::Task["db:schema:version"].invoke
98
98
  end
@@ -110,7 +110,7 @@ namespace :db do
110
110
  raise "VERSION is required" unless args[:version]
111
111
 
112
112
  puts "migrating up to version #{args.version}"
113
- Sequel::Migrator.apply(DB, File.join(APP_ROOT, 'db', 'migrate'), args.version)
113
+ Sequel::Migrator.apply(DB, File.join(SEQUEL_PLUS_APP_ROOT, 'db', 'migrate'), args.version)
114
114
  Rake::Task["db:schema:dump"].invoke
115
115
  end
116
116
 
@@ -122,7 +122,7 @@ namespace :db do
122
122
  down_version = 0 if down_version < 0
123
123
 
124
124
  puts "migrating down to version #{down_version}"
125
- Sequel::Migrator.apply(DB, File.join(APP_ROOT, 'db', 'migrate'), down_version)
125
+ Sequel::Migrator.apply(DB, File.join(SEQUEL_PLUS_APP_ROOT, 'db', 'migrate'), down_version)
126
126
  Rake::Task["db:schema:dump"].invoke
127
127
  end
128
128
 
@@ -133,7 +133,7 @@ namespace :db do
133
133
  else
134
134
  table = args.table
135
135
  verb = args.verb || 'create'
136
- migrate_path = File.join(APP_ROOT,'db', 'migrate')
136
+ migrate_path = File.join(SEQUEL_PLUS_APP_ROOT,'db', 'migrate')
137
137
  begin
138
138
  last_file = File.basename(Dir.glob(File.join(migrate_path, '*.rb')).sort.last)
139
139
  next_value = last_file.scan(/\d+/).first.to_i + 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Lang