schema_plus_core 0.4.0 → 0.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: 6c31ad40eecda53151aef2e6b0faac2a6f99385e
4
- data.tar.gz: eb7b4fa4146a8d2b6746391564b011f77f366b9a
3
+ metadata.gz: a978412d76ba8b0c72db34834af656872f6a4c73
4
+ data.tar.gz: ed0b82c25387fc6b9a1464befd68b241b0c984ed
5
5
  SHA512:
6
- metadata.gz: 90aad35397d7224e1ea32e712f27f4c1597b562245e9b6cdddb7d15add80e772d61bfbdfb7584b41e63192794ee110c354798cc119237870ac3dd3972bcf42dd
7
- data.tar.gz: 2fbdbb53cd67cf6830caba374d039c7e4e1419cb1986008005f04363566ad794b47146d8aa86c139454b4177c69e611680fff25d5678245d6fc5646b8a5b82a2
6
+ metadata.gz: bf7b398e3ba184a42f3204eb2b3739c2fd5eca7ac82a2ca85174c4335192819e64f9be7bb9f5ef3de33681279ca138f45b8640835aadc83fbb13f7b8cc9396e0
7
+ data.tar.gz: d061cd05ad32e49111cc84f8ada60b6251a0f852a96a0c4e85c26e2dd0484fed08a3759160622999a946e742f83c7acd4fa117e65f0a3c0ee73ba322275d4aae
data/README.md CHANGED
@@ -237,6 +237,18 @@ Stacks for operations that change the schema. In some cases the operation immed
237
237
 
238
238
  The base implementation drops the table. No value is returned.
239
239
 
240
+ * `Migration::RenameTable`
241
+
242
+ Renames a table
243
+
244
+ Env Field | Description | Initialized
245
+ --- | --- | ---
246
+ `:connection` | The current ActiveRecord connection | *context*
247
+ `:table_name` | The existing name of the table | *arg*
248
+ `:new_name` | The target name of the table | *arg*
249
+
250
+ The base implementation renames the table. No value is returned.
251
+
240
252
  * `Migration::Index`
241
253
 
242
254
  Callback stack for various ways to define an index.
@@ -438,6 +450,7 @@ SchemaPlus::Core provides a state object and of callbacks to various phases of t
438
450
 
439
451
  ## History
440
452
 
453
+ * 0.5.0 Added `Migration::DropTable`
441
454
  * 0.4.0 Add `implements_reference` to `Migration::Column` stack env
442
455
  * 0.3.1 Pass along (undocumented) return values from association declarations
443
456
  * 0.3.0 Added `Model::Association::Declaration`
@@ -22,6 +22,12 @@ module SchemaPlus
22
22
  end
23
23
  end
24
24
 
25
+ def rename_table(table_name, new_name)
26
+ SchemaMonkey::Middleware::Migration::RenameTable.start(connection: self, table_name: table_name, new_name: new_name) do |env|
27
+ super env.table_name, env.new_name
28
+ end
29
+ end
30
+
25
31
  def indexes(table_name, query_name=nil)
26
32
  SchemaMonkey::Middleware::Schema::Indexes.start(connection: self, table_name: table_name, query_name: query_name, index_definitions: []) { |env|
27
33
  env.index_definitions += super env.table_name, env.query_name
@@ -22,6 +22,12 @@ module SchemaPlus
22
22
  end
23
23
  end
24
24
 
25
+ def rename_table(table_name, new_name)
26
+ SchemaMonkey::Middleware::Migration::RenameTable.start(connection: self, table_name: table_name, new_name: new_name) do |env|
27
+ super env.table_name, env.new_name
28
+ end
29
+ end
30
+
25
31
  def exec_cache(sql, name, binds)
26
32
  SchemaMonkey::Middleware::Query::Exec.start(connection: self, sql: sql, query_name: name, binds: binds) { |env|
27
33
  env.result = super env.sql, env.query_name, env.binds
@@ -4,6 +4,12 @@ module SchemaPlus
4
4
  module ConnectionAdapters
5
5
  module Sqlite3Adapter
6
6
 
7
+ def rename_table(table_name, new_name)
8
+ SchemaMonkey::Middleware::Migration::RenameTable.start(connection: self, table_name: table_name, new_name: new_name) do |env|
9
+ super env.table_name, env.new_name
10
+ end
11
+ end
12
+
7
13
  def change_column(table_name, name, type, options = {})
8
14
  SchemaMonkey::Middleware::Migration::Column.start(caller: self, operation: :change, table_name: table_name, column_name: name, type: type, options: options.deep_dup) do |env|
9
15
  super env.table_name, env.column_name, env.type, env.options
@@ -37,6 +37,10 @@ module SchemaPlus
37
37
  ENV = [:connection, :table_name, :options]
38
38
  end
39
39
 
40
+ module RenameTable
41
+ ENV = [:connection, :table_name, :new_name]
42
+ end
43
+
40
44
  module Index
41
45
  ENV = [:caller, :operation, :table_name, :column_names, :options]
42
46
  end
@@ -1,5 +1,5 @@
1
1
  module SchemaPlus
2
2
  module Core
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -11,7 +11,7 @@ module SchemaPlus
11
11
  autoload :Sqlite3Adapter, DIR + "sqlite3_adapter"
12
12
  end
13
13
  end
14
- end
14
+ end
15
15
  end
16
16
 
17
17
  require_relative "core/active_record/base"
@@ -71,6 +71,10 @@ describe SchemaMonkey::Middleware do
71
71
  Then { expect_middleware { connection.drop_table "things" } }
72
72
  end
73
73
 
74
+ context TestReporter::Middleware::Migration::RenameTable do
75
+ Then { expect_middleware { connection.rename_table "things", "newthings" } }
76
+ end
77
+
74
78
  context TestReporter::Middleware::Migration::Index do
75
79
  Given { migration.add_column("things", "column1", "integer") }
76
80
  Then { expect_middleware { table_statement(:index, "id") } }
@@ -34,6 +34,7 @@ module TestReporter
34
34
  module Column ; include Notify ; end
35
35
  module CreateTable ; include Notify ; end
36
36
  module DropTable ; include Notify ; end
37
+ module RenameTable ; include Notify ; end
37
38
  module Index ; include Notify ; end
38
39
  end
39
40
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_plus_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ronen barzel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-17 00:00:00.000000000 Z
11
+ date: 2015-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord