secondbase 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/generators/secondbase/USAGE +1 -16
- data/rails_generators/secondbase/USAGE +29 -0
- data/rails_generators/secondbase/secondbase_migration_generator.rb +20 -0
- data/rails_generators/secondbase/templates/migration.rb +15 -0
- data/secondbase.gemspec +8 -2
- metadata +23 -4
data/Rakefile
CHANGED
@@ -19,6 +19,7 @@ Jeweler::Tasks.new do |gem|
|
|
19
19
|
gem.description = %Q{Secondbase provides support to Rails to create a homogeneous for a dual database project. Using the rake tasks already familiar to you, this gem enables Rails to work with two primary databases, instead of just one.}
|
20
20
|
gem.email = "kdurante@customink.com"
|
21
21
|
gem.authors = ["karledurante"]
|
22
|
+
gem.add_development_dependency 'activerecord', '~> 3.0.0'
|
22
23
|
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
24
|
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
25
|
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
@@ -9,26 +9,11 @@ Description:
|
|
9
9
|
column lines from supplied attributes: AddColumnsToTable or RemoveColumnsFromTable
|
10
10
|
|
11
11
|
Example:
|
12
|
-
`rails generate
|
12
|
+
`rails generate secondbase:migration AddSslFlag`
|
13
13
|
|
14
14
|
If the current date is May 14, 2008 and the current time 09:09:12, this creates the AddSslFlag migration
|
15
15
|
db/migrate/secondbase/20080514090912_add_ssl_flag.rb
|
16
16
|
|
17
|
-
`rails generate secondbase_migration AddTitleBodyToPost title:string body:text published:boolean`
|
18
|
-
|
19
|
-
This will create the AddTitleBodyToPost in db/migrate/secondbase/20080514090912_add_title_body_to_post.rb with
|
20
|
-
this in the Up migration:
|
21
|
-
|
22
|
-
add_column :posts, :title, :string
|
23
|
-
add_column :posts, :body, :text
|
24
|
-
add_column :posts, :published, :boolean
|
25
|
-
|
26
|
-
And this in the Down migration:
|
27
|
-
|
28
|
-
remove_column :posts, :published
|
29
|
-
remove_column :posts, :body
|
30
|
-
remove_column :posts, :title
|
31
|
-
|
32
17
|
You can continue to use `rake db:migrate` to migrate your first and second databases, or you can
|
33
18
|
target secondbase by using `rake db:migrate:secondbase`. Remember, your migrations are timestamped,
|
34
19
|
so regardless of the database they target, they will be unique and you will not have collision issues.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new database migration. Pass the migration name, either
|
3
|
+
CamelCased or under_scored, and an optional list of attribute pairs as arguments.
|
4
|
+
|
5
|
+
A migration class is generated in db/migrate_mysql prefixed by a timestamp of the current date and time.
|
6
|
+
|
7
|
+
You can name your migration in either of these formats to generate add/remove
|
8
|
+
column lines from supplied attributes: AddColumnsToTable or RemoveColumnsFromTable
|
9
|
+
|
10
|
+
Example:
|
11
|
+
`./script/generate secondbase_migration AddSslFlag`
|
12
|
+
|
13
|
+
If the current date is May 14, 2008 and the current time 09:09:12, this creates the AddSslFlag migration
|
14
|
+
db/migrate_mysql/20080514090912_add_ssl_flag.rb
|
15
|
+
|
16
|
+
`./script/generate secondbase_migration AddTitleBodyToPost title:string body:text published:boolean`
|
17
|
+
|
18
|
+
This will create the AddTitleBodyToPost in db/migrate_mysql/20080514090912_add_title_body_to_post.rb with
|
19
|
+
this in the Up migration:
|
20
|
+
|
21
|
+
add_column :posts, :title, :string
|
22
|
+
add_column :posts, :body, :text
|
23
|
+
add_column :posts, :published, :boolean
|
24
|
+
|
25
|
+
And this in the Down migration:
|
26
|
+
|
27
|
+
remove_column :posts, :published
|
28
|
+
remove_column :posts, :body
|
29
|
+
remove_column :posts, :title
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class SecondbaseMigrationGenerator < Rails::Generator::NamedBase
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
m.migration_template 'migration.rb', "db/migrate/#{SecondBase::CONNECTION_PREFIX}", :assigns => get_local_assigns
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
private
|
10
|
+
def get_local_assigns
|
11
|
+
returning(assigns = {}) do
|
12
|
+
if class_name.underscore =~ /^(add|remove)_.*_(?:to|from)_(.*)/
|
13
|
+
assigns[:migration_action] = $1
|
14
|
+
assigns[:table_name] = $2.pluralize
|
15
|
+
else
|
16
|
+
assigns[:attributes] = []
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class <%= class_name.underscore.camelize %> < ActiveRecord::Migration
|
2
|
+
############################################################
|
3
|
+
# Database migration targeting the Secondbase!
|
4
|
+
# Generated using: ./script/generator secondbase_migration [ModelName]
|
5
|
+
|
6
|
+
def self.up<% attributes.each do |attribute| %>
|
7
|
+
<%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end -%>
|
8
|
+
<%- end %>
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down<% attributes.reverse.each do |attribute| %>
|
12
|
+
<%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><% end -%>
|
13
|
+
<%- end %>
|
14
|
+
end
|
15
|
+
end
|
data/secondbase.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{secondbase}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["karledurante"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-28}
|
13
13
|
s.description = %q{Secondbase provides support to Rails to create a homogeneous for a dual database project. Using the rake tasks already familiar to you, this gem enables Rails to work with two primary databases, instead of just one.}
|
14
14
|
s.email = %q{kdurante@customink.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -33,6 +33,9 @@ Gem::Specification.new do |s|
|
|
33
33
|
"lib/secondbase/railtie.rb",
|
34
34
|
"lib/secondbase/rake_method_chain.rb",
|
35
35
|
"lib/secondbase/tasks.rb",
|
36
|
+
"rails_generators/secondbase/USAGE",
|
37
|
+
"rails_generators/secondbase/secondbase_migration_generator.rb",
|
38
|
+
"rails_generators/secondbase/templates/migration.rb",
|
36
39
|
"secondbase.gemspec",
|
37
40
|
"test/helper.rb",
|
38
41
|
"test/test_secondbase.rb"
|
@@ -56,17 +59,20 @@ Gem::Specification.new do |s|
|
|
56
59
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
57
60
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
|
58
61
|
s.add_development_dependency(%q<activerecord>, ["~> 3.0.0"])
|
62
|
+
s.add_development_dependency(%q<activerecord>, ["~> 3.0.0"])
|
59
63
|
else
|
60
64
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
61
65
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
62
66
|
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
63
67
|
s.add_dependency(%q<activerecord>, ["~> 3.0.0"])
|
68
|
+
s.add_dependency(%q<activerecord>, ["~> 3.0.0"])
|
64
69
|
end
|
65
70
|
else
|
66
71
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
67
72
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
68
73
|
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
69
74
|
s.add_dependency(%q<activerecord>, ["~> 3.0.0"])
|
75
|
+
s.add_dependency(%q<activerecord>, ["~> 3.0.0"])
|
70
76
|
end
|
71
77
|
end
|
72
78
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secondbase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- karledurante
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-28 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -80,6 +80,22 @@ dependencies:
|
|
80
80
|
- 0
|
81
81
|
version: 3.0.0
|
82
82
|
requirement: *id004
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
prerelease: false
|
85
|
+
type: :development
|
86
|
+
name: activerecord
|
87
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ~>
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 7
|
93
|
+
segments:
|
94
|
+
- 3
|
95
|
+
- 0
|
96
|
+
- 0
|
97
|
+
version: 3.0.0
|
98
|
+
requirement: *id005
|
83
99
|
description: Secondbase provides support to Rails to create a homogeneous for a dual database project. Using the rake tasks already familiar to you, this gem enables Rails to work with two primary databases, instead of just one.
|
84
100
|
email: kdurante@customink.com
|
85
101
|
executables: []
|
@@ -106,6 +122,9 @@ files:
|
|
106
122
|
- lib/secondbase/railtie.rb
|
107
123
|
- lib/secondbase/rake_method_chain.rb
|
108
124
|
- lib/secondbase/tasks.rb
|
125
|
+
- rails_generators/secondbase/USAGE
|
126
|
+
- rails_generators/secondbase/secondbase_migration_generator.rb
|
127
|
+
- rails_generators/secondbase/templates/migration.rb
|
109
128
|
- secondbase.gemspec
|
110
129
|
- test/helper.rb
|
111
130
|
- test/test_secondbase.rb
|