schema_plus_core 0.4.0 → 0.5.0
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.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/schema_plus/core/active_record/connection_adapters/mysql2_adapter.rb +6 -0
- data/lib/schema_plus/core/active_record/connection_adapters/postgresql_adapter.rb +6 -0
- data/lib/schema_plus/core/active_record/connection_adapters/sqlite3_adapter.rb +6 -0
- data/lib/schema_plus/core/middleware.rb +4 -0
- data/lib/schema_plus/core/version.rb +1 -1
- data/lib/schema_plus/core.rb +1 -1
- data/spec/middleware_spec.rb +4 -0
- data/spec/support/test_reporter.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a978412d76ba8b0c72db34834af656872f6a4c73
|
4
|
+
data.tar.gz: ed0b82c25387fc6b9a1464befd68b241b0c984ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/schema_plus/core.rb
CHANGED
data/spec/middleware_spec.rb
CHANGED
@@ -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") } }
|
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
|
+
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-
|
11
|
+
date: 2015-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|