splashblot / dronedb

Location Intelligence & Data Visualization tool
http://carto.com
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Hide, fix and show rename and duplicate raster datasets option #86

Closed apercas closed 6 years ago

apercas commented 6 years ago

Steps to Reproduce

  1. Open a raster type dataset view
  2. Explore those three dots at the end of the name
  3. Select duplicate or rename

image

Current Result

Both seem to work but their useless because when you rename a raster dataset it doesn't update the name of its overviews, and it doesn't duplicate them either

Expected result

A proper renaming and duplicating feature affecting all instances of the stack, regocijo y paz mundial

ivanprado commented 6 years ago

Look how vectorial overviews seems to be renamed: https://github.com/splashblot/dronedb/blob/tileo/app/models/table.rb#L1078

ivanprado commented 6 years ago

I have seen that overviews contains reference to original table by table name and the references doesn't seems to update on table rename. Use \d+ from psql over a overview to see the reference.

apercas commented 6 years ago

Postgis forums suggesting ALTER TABLEs queries: http://postgis.17.x6.nabble.com/Renaming-Raster-Table-td5011324.html

apercas commented 6 years ago

Hide logic deployed to beta.

apercas commented 6 years ago

Rough and dirty code for the rename:

        #hotfix for rasters
                if table_name.include? "_raster"
                        i = 1
                        #new_table_name.slice! "_raster"
                        #new_table_name = new_table_name + "_raster"
                        while i < 2
                                puts 'RUNNING: `ALTER TABLE o_'+i.to_s+'_'+table_name+' RENAME TO o_'+i.to_s+'_' +new_table_name
                                @database.execute %{
                                        SELECT DropOverviewConstraints('public', 'o_#{i}_#{table_name}', 'the_raster_webmercator');
                                }
                                @database.execute %{
                                        ALTER TABLE #{table_name} RENAME TO #{new_table_name};
                                        ALTER TABLE o_#{i}_#{table_name} RENAME TO o_#{i}_#{new_table_name};

                                }
                                @database.execute %{
                                        SELECT AddOverviewConstraints('public','o_#{i}_#{new_table_name}','the_raster_webmercator','public','#{new_table_name}','the_raster_webmercator',#{i});
                                }
                                i +=1
                        end
                end
        puts table_name + ' renamed ' + new_table_name
apercas commented 6 years ago

It actually works and update the stats :') https://github.com/splashblot/dronedb/commit/855890aa48be33399dd3b4e7a3ffd9a6874117bc

apercas commented 6 years ago

Rename deployed to beta.

apercas commented 6 years ago

Rename deployed to prod.