jcnetdev-auto_migrations 1.2.20080704 → 1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/auto_migrations.gemspec +2 -2
- data/lib/auto_migrations.rb +8 -5
- metadata +2 -2
data/auto_migrations.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'auto_migrations'
|
3
|
-
s.version = '1.
|
4
|
-
s.date = '2008-
|
3
|
+
s.version = '1.3'
|
4
|
+
s.date = '2008-09-01'
|
5
5
|
|
6
6
|
s.summary = "Allows migrations to be run automatically based on updating the schema.rb"
|
7
7
|
s.description = "Forget migrations, auto-migrate!"
|
data/lib/auto_migrations.rb
CHANGED
@@ -5,7 +5,7 @@ module AutoMigrations
|
|
5
5
|
class << ActiveRecord::Schema
|
6
6
|
alias :old_define :define
|
7
7
|
attr_accessor :version
|
8
|
-
def define(info={}, &block) @version=
|
8
|
+
def define(info={}, &block) @version = Time.now.utc.strftime("%Y%m%d%H%M%S"); instance_eval(&block) end
|
9
9
|
end
|
10
10
|
|
11
11
|
load(File.join(RAILS_ROOT, 'db', 'schema.rb'))
|
@@ -39,8 +39,7 @@ module AutoMigrations
|
|
39
39
|
class << base
|
40
40
|
cattr_accessor :tables_in_schema, :indexes_in_schema
|
41
41
|
self.tables_in_schema, self.indexes_in_schema = [], []
|
42
|
-
|
43
|
-
alias_method_chain :method_missing, :auto_migration unless instance_methods.include?('method_missing_without_auto_migration')
|
42
|
+
alias_method_chain :method_missing, :auto_migration
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
@@ -135,8 +134,12 @@ module AutoMigrations
|
|
135
134
|
end
|
136
135
|
|
137
136
|
def update_schema_version(version)
|
138
|
-
|
139
|
-
|
137
|
+
ActiveRecord::Base.connection.update("INSERT INTO schema_migrations VALUES ('#{version}')")
|
138
|
+
|
139
|
+
schema_file = File.join(RAILS_ROOT, "db", "schema.rb")
|
140
|
+
schema = File.read(schema_file)
|
141
|
+
schema.sub!(/:version => \d+/, ":version => #{version}")
|
142
|
+
File.open(schema_file, "w") { |f| f << schema }
|
140
143
|
end
|
141
144
|
|
142
145
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jcnetdev-auto_migrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: "1.3"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PJ Hyett
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-09-01 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|