sinatra-activerecord 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebc762631ec940416f6da6a0556185e825435d19
4
- data.tar.gz: 803dbda8bdd9f0d0337a1b5a76e498325b759d07
3
+ metadata.gz: 55dde46fae3e419004fc3d736d20cc9f3a264dfb
4
+ data.tar.gz: cedff4d701cc24e94c1709cf9260a63b4173a72d
5
5
  SHA512:
6
- metadata.gz: c549c27517bf69e71989ca6c0e538e69bf81f83876a3236ad5dcc65b48f3c5a276365ae2c46046b00fcbab7d5cdc9fdcf767a8b35f3b2ebb416ca668a8fbc1bd
7
- data.tar.gz: e26325d3743f08312be6d94feeb67edd44864d1cbf4f1a22f25ae5c343ba8ce6632b9fe1b8a95bfb046303f5dfc8560a7a83f7a6b8a095d2564d513f37c34622
6
+ metadata.gz: d13de960d2b4110c257c2997227930e009f302523f0a69743d12b9fbb5ae53247b0cbdc8165f945263e1abdcbee474e4248d21f772b516061247521bc5152547
7
+ data.tar.gz: 30137e9fe91ea7207c05db286bb94d691177dbbac6cd5d3255482627e912523ce7a6a1065f87fecd9d5f7ffac381cab265cd57f09f2878e84449e517e1e8e6ea
@@ -78,6 +78,10 @@ module Sinatra
78
78
  end
79
79
  end
80
80
 
81
+ def dump_structure(file_name = 'db/structure.sql')
82
+ ActiveRecord::Tasks::DatabaseTasks.structure_dump(config, file_name)
83
+ end
84
+
81
85
  def purge
82
86
  if config
83
87
  ActiveRecord::Tasks::DatabaseTasks.purge(config)
@@ -90,6 +94,10 @@ module Sinatra
90
94
  load(file_name)
91
95
  end
92
96
 
97
+ def load_structure(file_name = 'db/structure.sql')
98
+ ActiveRecord::Tasks::DatabaseTasks.structure_load(config, file_name)
99
+ end
100
+
93
101
  def with_config_environment(environment, &block)
94
102
  previous_environment = config_environment
95
103
  begin
@@ -111,7 +119,9 @@ module Sinatra
111
119
  end
112
120
 
113
121
  def config
114
- ActiveRecord::Base.configurations[config_environment]
122
+ ActiveRecord::Base.configurations[config_environment] ||
123
+ #active record expects the keys to be strings, but connection_config returns them as symbols
124
+ Hash[ActiveRecord::Base.connection_config.map{|key, value| [key.to_s, value]}]
115
125
  end
116
126
 
117
127
  def migrations_dir
@@ -29,13 +29,21 @@ namespace :db do
29
29
  desc "migrate the database (use version with VERSION=n)"
30
30
  task :migrate do
31
31
  Sinatra::ActiveRecordTasks.migrate(ENV["VERSION"])
32
- Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
32
+
33
+ case ActiveRecord::Base.schema_format
34
+ when :ruby then Rake::Task["db:schema:dump"].invoke
35
+ when :sql then Rake::Task["db:structure:dump"].invoke
36
+ end
33
37
  end
34
38
 
35
39
  desc "roll back the migration (use steps with STEP=n)"
36
40
  task :rollback do
37
41
  Sinatra::ActiveRecordTasks.rollback(ENV["STEP"])
38
- Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
42
+
43
+ case ActiveRecord::Base.schema_format
44
+ when :ruby then Rake::Task["db:schema:dump"].invoke
45
+ when :sql then Rake::Task["db:structure:dump"].invoke
46
+ end
39
47
  end
40
48
 
41
49
  namespace :schema do
@@ -50,6 +58,18 @@ namespace :db do
50
58
  end
51
59
  end
52
60
 
61
+ namespace :structure do
62
+ desc "dump schema into a file as SQL"
63
+ task :dump do
64
+ Sinatra::ActiveRecordTasks.dump_structure()
65
+ end
66
+
67
+ desc "load schema into database"
68
+ task :load do
69
+ Sinatra::ActiveRecordTasks.load_structure()
70
+ end
71
+ end
72
+
53
73
  namespace :test do
54
74
  task :purge do
55
75
  Sinatra::ActiveRecordTasks.with_config_environment 'test' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Mizerany
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-03 00:00:00.000000000 Z
12
+ date: 2014-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra