mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-27 17:30:32 +08:00
SCI-2936 minor refactor and code styling
This commit is contained in:
parent
f6230b2c9a
commit
2271e453df
1 changed files with 18 additions and 16 deletions
|
@ -26,15 +26,16 @@ class ChangeIndicesFromIntToBigint < ActiveRecord::Migration[5.1]
|
||||||
EOM
|
EOM
|
||||||
keys = execute(sql)
|
keys = execute(sql)
|
||||||
|
|
||||||
|
if keys.any?
|
||||||
# get all user defined views
|
# get all user defined views
|
||||||
user_viewes = execute(
|
user_viewes = execute(
|
||||||
"select * from pg_views where schemaname = any (current_schemas(false))"
|
"select * from pg_views where schemaname = any (current_schemas(false))"
|
||||||
) if keys.any?
|
)
|
||||||
|
|
||||||
# drop all existing views
|
# drop all existing views
|
||||||
user_viewes.each do |user_view|
|
user_viewes.each do |user_view|
|
||||||
execute("drop view #{user_view['viewname']}")
|
execute("drop view #{user_view['viewname']}")
|
||||||
end if keys.any?
|
end
|
||||||
|
|
||||||
# change all keys
|
# change all keys
|
||||||
keys.each do |key|
|
keys.each do |key|
|
||||||
|
@ -44,7 +45,8 @@ class ChangeIndicesFromIntToBigint < ActiveRecord::Migration[5.1]
|
||||||
# recreate user defined views
|
# recreate user defined views
|
||||||
user_viewes.each do |user_view|
|
user_viewes.each do |user_view|
|
||||||
execute("create view #{user_view['viewname']} as #{user_view['definition']}")
|
execute("create view #{user_view['viewname']} as #{user_view['definition']}")
|
||||||
end if keys.any?
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
|
Loading…
Reference in a new issue