Is it possible to create an empty or dummy index in postgres? I am working on cleaning up a database so that an application upgrade script can run. The state is that the upgrade script expects an index to exist only so that it can drop that index. The index was dropped in production by hand some time ago. Artificially altering the upgrade script or telling the upgrade process it has already run that step isn't an option for non-technical reasons beyond my control. 

Instead of taking the time to recreate the index is it possible to create a "dummy" or empty index with the same name so that the upgrade script can run?

This is for postgresql 9.0 or later.
upgrade script expects an index to exist only so that it can drop that index [...] Instead of taking the time to recreate the index is it possible to create a "dummy" or empty index with the same name so that the upgrade script can run?


Just delete that line from the update script. Or even better, use the IF EXISTS clause so it throws a notice not an error.

Command:     DROP INDEX
Description: remove an index
Syntax:
DROP INDEX [ CONCURRENTLY ] [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]


But yes, the DROP INDEX doesn't even know if the index is on a specified table if you're dropping by index name and not by table(column) location.

Here is an example,

CREATE TABLE foo ( x int );
CREATE INDEX ON foo(x);
CREATE TABLE bar ( LIKE foo );

\d foo;
      Table "public.foo"
 Column |  Type   | Modifiers 
--------+---------+-----------
 x      | integer | 
Indexes:
    "foo_x_idx" btree (x)

--
-- HERE WE DROP FOR THE FIRST TIME
--
DROP INDEX foo_x_idx ;
DROP INDEX

--
-- RECREATE
--
CREATE INDEX foo_x_idx ON bar(x);

--
-- DROP AGAIN
--
DROP INDEX foo_x_idx;
DROP INDEX