db-charmer 1.5.4 → 1.5.5
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/CHANGES +26 -7
- data/README.rdoc +17 -0
- data/VERSION +1 -1
- data/db-charmer.gemspec +2 -2
- data/lib/db_charmer/multi_db_migrations.rb +4 -3
- metadata +3 -3
data/CHANGES
CHANGED
@@ -1,20 +1,40 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.5 (2010-03-15):
|
2
|
+
|
3
|
+
Thanks to ngmoco.com (http://github.com/ngmoco) now DbCharmer supports one more use-case
|
4
|
+
for multi-db migrations. Now you can run the same migration on many databases at once.
|
5
|
+
For example, the following migration would create test_table on all three shard databases:
|
6
|
+
|
7
|
+
class MultiDbTest < ActiveRecord::Migration
|
8
|
+
db_magic :connections => [ :shard01, :shard02, :shard03 ]
|
9
|
+
|
10
|
+
def self.up
|
11
|
+
create_table :test_table do |t|
|
12
|
+
t.string :test_string
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.down
|
18
|
+
drop_table :test_table
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
----------------------------------------------------------------------------------------
|
23
|
+
1.5.4 (2010-03-12):
|
2
24
|
|
3
25
|
Added DbCharmer.with_remapped_databases, so that you can change the connection for
|
4
26
|
many models simultaneously, and implicitly. Very useful for work where you want to use
|
5
27
|
a particular slave for a whole range of database access.
|
6
28
|
|
7
29
|
----------------------------------------------------------------------------------------
|
8
|
-
|
9
|
-
1.5.1 -> 1.5.3:
|
30
|
+
1.5.3 (2010-03-10):
|
10
31
|
|
11
32
|
Few changes:
|
12
33
|
* Colorized connection names in the logs for development mode
|
13
34
|
* We do not log connection names when connection does not exist
|
14
35
|
|
15
36
|
----------------------------------------------------------------------------------------
|
16
|
-
|
17
|
-
1.5.0 -> 1.5.1:
|
37
|
+
1.5.1 (2010-03-06):
|
18
38
|
|
19
39
|
In this version we've added support for connection names logging in Rails queries log.
|
20
40
|
New log records have [connection_name] prefix for all queries that are executed on
|
@@ -25,8 +45,7 @@ non-standard connections:
|
|
25
45
|
[slave01] User Load (0.2ms) SELECT * FROM `users` WHERE (`users`.`login` = 'foo')
|
26
46
|
|
27
47
|
----------------------------------------------------------------------------------------
|
28
|
-
|
29
|
-
1.4.6 -> 1.5.0:
|
48
|
+
1.4.6 -> 1.5.0 (2010-03-05):
|
30
49
|
|
31
50
|
Major change in this version of DbCharmer is association preload support. For example,
|
32
51
|
let's say we have a schema:
|
data/README.rdoc
CHANGED
@@ -109,6 +109,23 @@ Migration class example (block-level connection rewrite):
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
+
Migration class example (global connection rewrite, multiple connections with the same table):
|
113
|
+
(NOTE: both :connection and :connections can take an array of connections)
|
114
|
+
|
115
|
+
class MultiDbTest < ActiveRecord::Migration
|
116
|
+
db_magic :connections => [:second_db, :default]
|
117
|
+
|
118
|
+
def self.up
|
119
|
+
create_table :test_table, :force => true do |t|
|
120
|
+
t.string :test_string
|
121
|
+
t.timestamps
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.down
|
126
|
+
drop_table :test_table
|
127
|
+
end
|
128
|
+
end
|
112
129
|
|
113
130
|
By default in development and test environments you could skip this <tt>:second_db</tt>
|
114
131
|
connection from your database.yml files and rails would create the tables in your single database,
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.5
|
data/db-charmer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{db-charmer}
|
8
|
-
s.version = "1.5.
|
8
|
+
s.version = "1.5.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alexey Kovyrin"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-15}
|
13
13
|
s.description = %q{ActiveRecord Connections Magic (slaves, multiple connections, etc)}
|
14
14
|
s.email = %q{alexey@kovyrin.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module DbCharmer
|
2
2
|
module MultiDbMigrations
|
3
|
-
|
3
|
+
@multi_db_names = nil
|
4
4
|
|
5
5
|
def migrate_with_db_wrapper(direction)
|
6
|
-
on_db(
|
6
|
+
@multi_db_names.each { |multi_db_name| on_db(multi_db_name) { migrate_without_db_wrapper(direction) } }
|
7
7
|
end
|
8
8
|
|
9
9
|
def on_db(db_name)
|
@@ -19,8 +19,9 @@ module DbCharmer
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def db_magic(opts = {})
|
22
|
+
opts[:connection] = opts[:connections] if opts[:connections]
|
22
23
|
raise ArgumentError, "No connection name - no magic!" unless opts[:connection]
|
23
|
-
|
24
|
+
@multi_db_names = [opts[:connection]].flatten
|
24
25
|
class << self
|
25
26
|
alias_method_chain :migrate, :db_wrapper
|
26
27
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 1.5.
|
8
|
+
- 5
|
9
|
+
version: 1.5.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alexey Kovyrin
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-15 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|