maxlapshin / mysql2postgres

Mysqldump, writing in postgresql format
MIT License
711 stars 156 forks source link

Error migrating moodle: syntax error in or next to "DEFAULT" (PGError) #4

Closed leleobhz closed 8 years ago

leleobhz commented 14 years ago

Creating table moodleenrol_authorize... Error: CREATE TABLE "moodleenrol_authorize" ( "id" integer DEFAULT nextval('moodleenrol_authorize_id_seq'::regclass) NOT NULL, "paymentmethod" character varying(6), check( paymentmethod in ('cc','echeck')) DEFAULT cc NOT NULL, "refundinfo" integer DEFAULT 0 NOT NULL, "ccname" character varying(255) NOT NULL, "courseid" bigint DEFAULT 0 NOT NULL, "userid" bigint DEFAULT 0 NOT NULL, "transid" bigint DEFAULT 0 NOT NULL, "status" bigint DEFAULT 0 NOT NULL, "timecreated" bigint DEFAULT 0 NOT NULL, "settletime" bigint DEFAULT 0 NOT NULL, "amount" character varying(10) NOT NULL, "currency" character(3) DEFAULT 'USD'::char NOT NULL ) WITHOUT OIDS; ./mysql2psql:466:in exec': ERRO: erro de sintaxe em ou próximo a "DEFAULT" (PGError) LINE 3: ...ying(6), check( paymentmethod in ('cc','echeck')) DEFAULT cc... ^ from ./mysql2psql:466:inwrite_table' from ./mysql2psql:617:in convert' from ./mysql2psql:616:ineach' from ./mysql2psql:616:in `convert' from ./mysql2psql:682

And the process die.

maxlapshin commented 14 years ago

Would you, kindly, paste mysql schema to some pastie and send it to me.

tardate commented 14 years ago

hi max, just started trying mysql2postgresql for a project here and ran into the same problem. The SQL generated for string enums is not quite right:

"paymentmethod" character varying(6), check( paymentmethod in ('cc','echeck')) DEFAULT cc NOT NULL,

should be more like:

"paymentmethod" character varying(6) check( paymentmethod in ('cc','echeck')) DEFAULT 'cc' NOT NULL,

i.e. no comma before check constraint, and default value quoted. Seeing if I can fork and fix this; will send you a pull request if so

tardate commented 14 years ago

I think this should be fixed as of http://github.com/maxlapshin/mysql2postgres/commit/973b1f11e317a3342c6d2c9230f642f8d1a25923

paazmaya commented 8 years ago

Closing as an old issue, that would seem to be out of date. Feel free to re-open and update with comments aganst the master branch.