Skip to content

Commit

Permalink
Merge pull request #16358 from CartoDB/bug/sc-184298/check-migration-…
Browse files Browse the repository at this point in the history
…process-for-old-plans

[sc184298] Update analysis schema when a user is promoted to organization owner
  • Loading branch information
Shylpx committed Oct 25, 2021
2 parents 0bbdf15 + e8f2592 commit 0f2aa2a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Development
- Allow importing datasets with exhausted map quota [#16320](https://github.com/CartoDB/cartodb/pull/16320)
- Fix empty ArcGIS imports [#16322](https://github.com/CartoDB/cartodb/pull/16322)
- Fix data overwrite when a user is promoted to admin [#16351](https://github.com/CartoDB/cartodb/pull/16351)
- Update analysis schema when a user is promoted to organization owner [#16358](https://github.com/CartoDB/cartodb/pull/16358)
- Add setting to disable diagnosis page [#16324](https://github.com/CartoDB/cartodb/pull/16324)
- Fix wrong layer schema when creating a map from a shared dataset [#16323](https://github.com/CartoDB/cartodb/pull/16323)
- Fix auto guessing when a csv field is wrong [#16326](https://github.com/CartoDB/cartodb/pull/16326)
Expand Down
20 changes: 20 additions & 0 deletions app/models/user/db_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,25 @@ def set_database_search_path
end
end

def update_analyses_schema
@user.carto_user.tables.each do |table|
table.dependent_visualizations.each do |visualization|
visualization.analyses.each do |analysis|
analysis.update_table_name(
"#{SCHEMA_PUBLIC}.#{table.name}",
"\"#{@user.database_schema}\".#{table.name}"
)
end
end
end
rescue StandardError => e
Rails.logger.error(
exception: e,
message: 'Error updating schema of user analyses while moving to own schema',
user: @user.username
)
end

def create_importer_schema
create_schema('cdb_importer')
end
Expand Down Expand Up @@ -1193,6 +1212,7 @@ def move_to_own_schema

create_public_db_user
set_database_search_path
update_analyses_schema
end
rescue StandardError => e
# Undo metadata changes if process fails
Expand Down

0 comments on commit 0f2aa2a

Please sign in to comment.