Skip to content

Commit

Permalink
always attempt to drop columns #6919
Browse files Browse the repository at this point in the history
On a new installation, the logic wasn't running and
haspreviewmode is being added by a previous SQL script.
  • Loading branch information
pdurbin committed Oct 28, 2020
1 parent 41f1ac8 commit 3e71d96
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/resources/db/migration/V5.1.1.2__6919-preview-tools.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
-- "externaltooltype".
DO $$
BEGIN
-- Only run these statements if "type" (and "haspreviewmode") still exist on the
-- externaltool table.
-- Migrate existing external tools into to new schema. This is for upgrades,
-- which have a "type" column from when the entity had a "type" field.
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name='externaltool' AND column_name='type') THEN
-- For each explore tool that has preview, make an EXPLORE row.
insert into externaltooltype(externaltool_id,type) select id,'EXPLORE' from externaltool where haspreviewmode = true and type = 'EXPLORE';
-- For each explore tool that has preview, make a PREVIEW row.
insert into externaltooltype(externaltool_id,type) select id,'PREVIEW' from externaltool where haspreviewmode = true and type = 'EXPLORE';
-- For all the other tools, make a row.
insert into externaltooltype(externaltool_id,type) select id,type from externaltool where haspreviewmode = false or type != 'EXPLORE';
-- Drop "type" and "haspreviewmode" from externaltool.
alter table externaltool drop column if exists type;
alter table externaltool drop column if exists haspreviewmode;
END IF;
-- Drop "type" and "haspreviewmode" from externaltool.
alter table externaltool drop column if exists type;
alter table externaltool drop column if exists haspreviewmode;
END
$$

0 comments on commit 3e71d96

Please sign in to comment.