switchman 1.11.2 → 1.11.3

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: 98fbc6b218fc11fd51c66e0762678059872165c8
4
- data.tar.gz: 397e886ea3a569721b58212f5d4e25d784810c6f
3
+ metadata.gz: e6c3cba2d388ad0dac874cc3afcb6b72400e059c
4
+ data.tar.gz: 0cccf4b90cafbbec5ff3e8cecf07fda96637c779
5
5
  SHA512:
6
- metadata.gz: 8edc7c2865448dfe0938c126fd85b7ffe73dd3a85da15b047aa3692793824cb96ae4504bf814cef2b4d5dc2da0301af844bfcbe7536b3b324f6bae7d9f5d06ad
7
- data.tar.gz: 512e25f85e28189e126f39db29437ca087b52c7ca1b508516e5f49d84c696331e74e67bfd57782f8a77b5ae8281fc09238c2f41bccfce0f4e5b7c567147073f5
6
+ metadata.gz: c2090842b65f0f0b3e27ef16b8b048afd5bf909485d3e89bf7c9a9877bd2474825f589ffc07999aecc3c17b02958e3ca817cd18b21065c99ed500191943b969a
7
+ data.tar.gz: 86cded89d28fdfee080ea9167a773a5c263960b732ca2c5216b58877d4f18f8eb2d0f51598471260de35bf3e40f1e9d0e8bed8372d009730f4d8ccbca965512a
@@ -214,6 +214,28 @@ module Switchman
214
214
  algorithm = nil if DatabaseServer.creating_new_shard && algorithm == "CONCURRENTLY"
215
215
  [index_name, index_type, index_columns, index_options, algorithm, using]
216
216
  end
217
+
218
+ def rename_table(table_name, new_name)
219
+ clear_cache!
220
+ execute "ALTER TABLE #{quote_table_name(table_name)} RENAME TO #{quote_local_table_name(new_name)}"
221
+ pk, seq = pk_and_sequence_for(new_name)
222
+ if pk
223
+ idx = "#{table_name}_pkey"
224
+ new_idx = "#{new_name}_pkey"
225
+ execute "ALTER INDEX #{quote_table_name(idx)} RENAME TO #{quote_local_table_name(new_idx)}"
226
+ if seq && seq.identifier == "#{table_name}_#{pk}_seq"
227
+ new_seq = "#{new_name}_#{pk}_seq"
228
+ execute "ALTER TABLE #{seq.quoted} RENAME TO #{quote_local_table_name(new_seq)}"
229
+ end
230
+ end
231
+ rename_table_indexes(table_name, new_name)
232
+ end
233
+
234
+ def rename_index(table_name, old_name, new_name)
235
+ validate_index_length!(table_name, new_name)
236
+
237
+ execute "ALTER INDEX #{quote_column_name(old_name)} RENAME TO #{quote_local_table_name(new_name)}"
238
+ end
217
239
  end
218
240
  end
219
241
  end
@@ -236,7 +236,7 @@ module Switchman
236
236
  current_source_shard =
237
237
  if source_shard
238
238
  source_shard
239
- elsif shard_source_value == :explicit
239
+ elsif shard_source_value == :explicit && !shard_value.is_a?(Array) && !shard_value.is_a?(::ActiveRecord::Relation)
240
240
  primary_shard
241
241
  elsif type == :primary
242
242
  Shard.current(klass.shard_category)
@@ -1,3 +1,3 @@
1
1
  module Switchman
2
- VERSION = "1.11.2"
2
+ VERSION = "1.11.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.2
4
+ version: 1.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-08-10 00:00:00.000000000 Z
13
+ date: 2017-09-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties