I read with great enthusiasm a question called Migrating from MySQL to PostgreSQL on Linux (Kubuntu) . The theme of Star Wars made it much more interesting. But I had a problem with Unique Constraints in PostgreSQL.
I carefully followed the post above to create PostgreSQL DDL using sqlt . The thought process was to create the schema / tables first and then import the data. However, 57 of my 72 tables use CONSTRAINT "userid" UNIQUE ("user_id", "key")
Here is an example of one of the tables:
CREATE TABLE "account_otherserviceinfo" ( "id" serial NOT NULL, "user_id" bigint NOT NULL, "key" character varying(50) NOT NULL, "value" text NOT NULL, PRIMARY KEY ("id"), CONSTRAINT "user_id" UNIQUE ("user_id", "key") );
When I copy these tables to my PostgreSQL database using the Query tool in pgadmin3, I get the following error:
ERROR: relation "user_id" already exists SQL state: 42P07
I did not design this database schema. I only help in the migration process. When you read the documentation about unique constraints, it seems that using one name is the same as in another table. http://www.postgresql.org/docs/8.3/static/ddl-constraints.html Am I misinterpreting this?
Any suggestions or pointers are welcome.
Thanks!
PS: Thank you https://stackoverflow.com/users/59087/dave-jarvis and https://stackoverflow.com/users/26534/michael-trausch for going this far; -)
source share