I am trying to alter the index name using liquibase using the below code, but it is not working. The same sql statement is working directly in the db.
<changeSet author="sai" dbms="postgresql">
<preConditions onFail="MARK_RAN">
<indexExists indexName="employee_id_idx" schemaName="public"/>
</preConditions>
<sql>alter INDEX employee_id_idx RENAME TO department_id_idx</sql>
</changeSet>
Could anyone please let me know if there is any other way of doing alter to the index name using liquibase.
It works fine with the same code. But when we run the code if we have any error in the code, then it will be saved in DBChangeLog table, we need to remove that particular record and run again. This resolved the issue
Related
I have a SQL ALTER statement to update an existing publication to add a table.
ALTER PUBLICATION publication_p1 ADD TABLE schema.tablename;
I want to add this line to an automated database versioning script. However I want to see if the publication would be added IF the table wasn't a member AND if the publication existed. So something like:
ALTER PUBLICATION IF EXISTS publication_p1 ADD TABLE IF NOT EXISTS schema.tablename;
I tried my idea, and obviously didn't work. Looking at the postgres documentation IF EXISTS is not supported.
Is there a way of applying something similar in POSTGRES?
Thanks
I've a script like the following:
SET search_path = MySchema;
INSERT INTO MyTable() values ()
MyTable is actually created in MySchema, so if I change the script to
INSERT INTO MySchema.MyTable() values ()
It works
Now I'm generating some SQL files to recreate a database structure, so we have the scripts generated with "SET search_path = MySchema;"
Is there a way to make this work?
Using NPGSQL version 3.0.4.0
My mistake, it's not related to the schema itself, the issue is when having both DDL and DML instructions together.
Setup:
liquibase 3.3.5
PostgreSQL 9.3
Windows 7 Ultimate
Having set the Liquibase.properties file with
changeLogFile = C://temp/changeset.xml,
I created a diff file with Liquibase (3.3.5).
liquibase.bat diffChangeLog
Examination of the changeset.xml file shows
-<addColumn tableName="view_dx">
<column type="int8" name="counter" defaultValueNumeric="0" defaultValue="0"/>
</addColumn
Problem is when
liquibase.bat update
is run, the changed table is NOT in the same column order as the reference table. This causes issues with the stored procedures using SETOF to return table rows.
Without destroying the existing table on the target database, how can column order be enforced using Liquibase?
TIA
I don't think that you can, in general, get Liquibase to enforce a column ordering. You will probably need to change your stored procedures to use column names rather than relying on position, which is a good habit to get into anyway.
Have you tried using afterColumn attribute of addColumn tag ?
In postgres how do I add index to existing table?
I tried following but it's not working:
CREATE INDEX my_index ON my_table USING btree(a_column);
and then this:
CREATE INDEX my_index ON my_table USING btree(a_column);
But neither works.
I am using ant to do a db migration. And when I do ant db-migrate-apply-postgresql I keep getting the error
[echo] ERROR: relation "my_index" already exists
Well, this error message:
ERROR: relation "my_index" already exists
is pretty clear, isn't it.
You are trying to create an index with the name of an existing index or table.
You need to use a different name.
We have a table someone created in DB2. I have no idea how they created it. But when I edit the table, It edits just fine. But after edit I can not query the table at all THE COLUMN CANNOT BE ADDED TO THE TABLE BECAUSE THE TABLE HAS AN EDIT PROCEDURE.
I looked ibm site and found this how to edit table using procedure
But I have no idea how to do this.
Is there anything that I can do to fix this with out following the procedure mentioned in second link?
I restarted server, but still no help. First I'm not able to figure out why I get the error in first place.
I'm using DB Visualizer and DB2 on linux.
This is sometimes default behavior of DB2. We need to run reorgchk command to fix these errors. More info below..
http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/r0000888.htm
http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/c0023297.htm