migratus
migratus copied to clipboard
Migration table failure against Oracle
https://github.com/yogthos/migratus/blob/master/src/migratus/database.clj#L213 uses 'BIGINT' for the Migrations table. This is not a valid datatype in Oracle land.
Yeah, looks like you would either need to detect the database type and use the correct type or allow passing custom types here.
I guess in the meantime, a workaround would be to manually create the table before running migrations.
I can confirm that this works.
There's a secondary problem here even when manually creating the table, namely there no JDBC mappings to a java.lang.Long
using the Oracle driver. Best mapping for the Postgres BIGINT
in Oracle would be a NUMBER
, but that's returned by JDBC as a java.math.BigDecimal
. This causes migratus.core/uncompleted-migrations
to fail its check because migratus.protocols/id
returns a java.lang.Long
; a java.math.BigDecimal
does not equal a java.lang.Long
even with the same value.
Perhaps it would be better to keep ids as some kind of string type column (e.g. VARCHAR
)? I'd assume JDBC always maps those to java.lang.String
. Either that or add coercion in migratus.database/completed-ids*
to ensure the ids returned are longs.
Using strings for ids should be fine, although that would break backwards compatibility. This looks like an existing issue as well. Perhaps it might be better to just explicitly cast to long
when comparing?
Yeah. Considering backwards compatibility, explicit coercion seems to be the easy fix. It still leaves the bug in Oracle where the migration table cannot be created automatically when it does not exist. However, since that can be alleviated by manually creating the table, it's less of an issue.
Two options would be to either try to infer the database type from the driver and use the type supported by it, or find a numeric type that most databases support. If the latter is possible, I think that would be ideal.
It looks like ANSI/ISO type should be double precision. The PlatformUtils class from the ApacheDdlUtils library could be used to infer the database type otherwise.
Hi i am having trouble migrating oracle..
Did you try creating the migrations table by hand?
(sql/create-table-ddl :schema_migrations
[[:id "NUMBER" "UNIQUE" "NOT NULL"]
[:applied "TIMESTAMP" "" ""]
[:description "VARCHAR(1024)" "" ""]])
This worked :) hi thanks for the help from the begining, and the quick response yogthos,