Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration table failure against Oracle #43

Open
dpassen opened this issue Oct 8, 2015 · 11 comments
Open

Migration table failure against Oracle #43

dpassen opened this issue Oct 8, 2015 · 11 comments

Comments

@dpassen
Copy link
Contributor

dpassen commented Oct 8, 2015

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.

@yogthos
Copy link
Owner

yogthos commented Oct 8, 2015

Yeah, looks like you would either need to detect the database type and use the correct type or allow passing custom types here.

@yogthos
Copy link
Owner

yogthos commented Oct 8, 2015

I guess in the meantime, a workaround would be to manually create the table before running migrations.

@dpassen
Copy link
Contributor Author

dpassen commented Oct 9, 2015

I can confirm that this works.

@alvinfrancis
Copy link

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.

@yogthos
Copy link
Owner

yogthos commented Jun 5, 2017

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?

@alvinfrancis
Copy link

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.

@yogthos
Copy link
Owner

yogthos commented Jun 5, 2017

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.

@yogthos
Copy link
Owner

yogthos commented Jun 5, 2017

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.

@mondaldebanjan
Copy link

Hi i am having trouble migrating oracle..

@yogthos
Copy link
Owner

yogthos commented Apr 4, 2018

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)" "" ""]])

@mondaldebanjan
Copy link

This worked :)
hi thanks for the help from the begining, and the quick response yogthos,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants