rein 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rein
2
2
 
3
- Database constraints made easy for ActiveRecord. Rein currently supports PostgreSQL and MySQL (foreign keys only).
3
+ Database constraints made easy for ActiveRecord. Rein currently supports PostgreSQL and MySQL (foreign keys only) for both Rails 2 & 3.
4
4
 
5
5
 
6
6
  ## Introduction
@@ -9,15 +9,18 @@ require 'active_record'
9
9
  require 'active_support/core_ext/hash'
10
10
 
11
11
  require 'rein/constraint/foreign_key'
12
+ require 'rein/constraint/primary_key'
12
13
  require 'rein/constraint/inclusion'
13
14
  require 'rein/constraint/numericality'
14
15
 
15
16
  module ActiveRecord::ConnectionAdapters
16
17
  class MysqlAdapter < AbstractAdapter
18
+ include RC::PrimaryKey
17
19
  include RC::ForeignKey
18
20
  end
19
21
 
20
22
  class PostgreSQLAdapter < AbstractAdapter
23
+ include RC::PrimaryKey
21
24
  include RC::ForeignKey
22
25
  include RC::Inclusion
23
26
  include RC::Numericality
@@ -0,0 +1,9 @@
1
+ module RC
2
+ module PrimaryKey
3
+ def add_primary_key(table, options = {})
4
+ attribute = "id".to_sym
5
+ sql = "ALTER TABLE #{table} ADD PRIMARY KEY (#{attribute})"
6
+ execute(sql)
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Rein
2
- VERSION = "0.4.0" unless defined?(Rein::VERSION)
2
+ VERSION = "0.5.0" unless defined?(Rein::VERSION)
3
3
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 4
7
+ - 5
8
8
  - 0
9
- version: 0.4.0
9
+ version: 0.5.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Josh Bassett
@@ -148,6 +148,7 @@ files:
148
148
  - lib/rein/constraint/foreign_key.rb
149
149
  - lib/rein/constraint/inclusion.rb
150
150
  - lib/rein/constraint/numericality.rb
151
+ - lib/rein/constraint/primary_key.rb
151
152
  - lib/rein/version.rb
152
153
  - lib/rein.rb
153
154
  - LICENSE
@@ -166,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
167
  requirements:
167
168
  - - ">="
168
169
  - !ruby/object:Gem::Version
169
- hash: 1339191596134317982
170
+ hash: 987002835671419802
170
171
  segments:
171
172
  - 0
172
173
  version: "0"