質問編集履歴
3
fix
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,7 +46,7 @@
|
|
46
46
|
|
47
47
|
rake.task
|
48
48
|
|
49
|
-
rake tenant:rename_tenant[huga,hoge]
|
49
|
+
rake tenant:rename_tenant[huga,hoge] # この場合current_nameにhuga、target_nameにhoge
|
50
50
|
|
51
51
|
|
52
52
|
|
2
shousai
test
CHANGED
File without changes
|
test
CHANGED
@@ -44,11 +44,25 @@
|
|
44
44
|
|
45
45
|
```Ruby
|
46
46
|
|
47
|
+
rake.task
|
48
|
+
|
49
|
+
rake tenant:rename_tenant[huga,hoge]
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
def self.rename_tenant(current_name, target_name)
|
54
|
+
|
55
|
+
...
|
56
|
+
|
57
|
+
...
|
58
|
+
|
47
|
-
sql = ActiveRecord::Base.sanitize_sql_array(['ALTER SCHEMA ? RENAME TO ?', current_name, target_name])
|
59
|
+
sql = ActiveRecord::Base.sanitize_sql_array(['ALTER SCHEMA ? RENAME TO ?', current_name, target_name])
|
48
60
|
|
49
61
|
sanitized_sql = ActiveRecord::Base.send(:sanitize_sql_array, sql)
|
50
62
|
|
51
63
|
ActiveRecord::Base.connection.execute(sanitized_sql)
|
64
|
+
|
65
|
+
end
|
52
66
|
|
53
67
|
```
|
54
68
|
|
1
shuusei
test
CHANGED
File without changes
|
test
CHANGED
@@ -44,7 +44,7 @@
|
|
44
44
|
|
45
45
|
```Ruby
|
46
46
|
|
47
|
-
sql = ActiveRecord::Base.sanitize_sql_array(['ALTER SCHEMA ? RENAME TO ?', current_name
|
47
|
+
sql = ActiveRecord::Base.sanitize_sql_array(['ALTER SCHEMA ? RENAME TO ?', current_name, target_name])
|
48
48
|
|
49
49
|
sanitized_sql = ActiveRecord::Base.send(:sanitize_sql_array, sql)
|
50
50
|
|