Coder Social home page Coder Social logo

luminus-migrations's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

luminus-migrations's Issues

Different behavior between "lein migratus" and "java -jar project.jar init"

I'm working on a small application which uses an H2 database.
Recently I added a table with some DECIMAL(18,10) and DECIMAL(19,4) columns. Because there were more changes to the database and it is just a prototype I'm working on the data in the database is not important. Therefore the migration script I made for the database first dropped all existing tables and then creates every table from scratch.

I see the following behavior:

  1. If I run "lein migratus" in my development environment a new empty database is created and I can start the application with "lein run"
  2. If I use "lein uberjar" to create a jar file and test this in a test folder on th same PC "java -Dconf=config.edn -jar project.jar init" (database url in config.edn file) a database file (only the mv not the trace variant) is created, but the process stops with a java.lang.NullPointerException. See below

read config from resource: "config.edn"
read config from file: "config.edn"
Exception in thread "main" java.lang.NullPointerException: entry
at java.util.zip.ZipFile.getInputStream(ZipFile.java:346)
at java.util.jar.JarFile.getInputStream(JarFile.java:447)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
at migratus.database$find_init_script_resource.invokeStatic(database.clj:105)
at migratus.database$find_init_script_resource.invoke(database.clj:98)
at migratus.database$find_init_script.invokeStatic(database.clj:112)
at migratus.database$find_init_script.invoke(database.clj:107)
at migratus.database$init_db_BANG_.invokeStatic(database.clj:180)
at migratus.database$init_db_BANG_.invoke(database.clj:179)
at migratus.database.Database.init(database.clj:194)
at migratus.core$init.invokeStatic(core.clj:128)
at migratus.core$init.doInvoke(core.clj:125)
at clojure.lang.RestFn.invoke(RestFn.java:410)
at luminus_migrations.core$init.invokeStatic(core.clj:36)
at luminus_migrations.core$init.invoke(core.clj:24)
at project.core$_main.invokeStatic(core.clj:58)
at project.core$_main.doInvoke(core.clj:53)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at project.core.main(Unknown Source)

However, if I take the database created in my development environment and copy this to the test environment I can run the application "java -Dconf=config.edn -jar project.jar" without any problem.

It looks to me that somehow the type DECIMAL caused the problem, because this was a new type I used in an extra table I added to my database.

Custom migration-table-name not supported?

I use migratus with a custom table name configured in project.clj like so:

:migratus {:store :database :migration-table-name "migratus" :db ~(get (System/getenv) "DATABASE_URL”)}

However, I don’t think it’s possible to use the custom table name with this command line wrapper, or perhaps I missed something?

Any help you can provide would be awesome. Thanks!

"java.lang.String to clojure.lang.IPersistentMap" cast error when running "lein test"

While going over the guestbook example from the "Web Development with Clojure, Second Edition" book, running lein test triggers:

Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IPersistentMap

I'm using a fresh clojure + leiningen + luminus install with the latest revision of luminus and the related dependencies.

Switching the luminus-migrations version from 0.2.2 to 0.1.9 or lower, makes the problem go away. So, this seems to have somthing to do with commit cfd4481.

Reverting the change at file src/luminus_migrations/core.clj in version 0.2.2 makes the error go away for me.

I didn't get this error when running lein run migrate.

Thanks!

v0.4.4 not on clojars

Luminus-template (with database functionality) is using luminus-migrations v0.4.4, which is not deployed to Clojars, so Leiningen can't download all project dependencies.

migrations destroy doesn't work

It seems there's a small error in migrate function as regards to destroy functionality.
When I run following, it doesn't work (doesn't remove anything)

;; Setup
(migrations/create "add-users-tmp" (select-keys env [:database-url]))
;; Destroy
(migrations/migrate ["destroy" "add-users-tmp"] (select-keys env [:database-url]))

However, using migratus directly works fine:

(migratus.core/destroy (select-keys env [:database-url]) "add-users-tmp")

My belief is that the error is in following code: https://github.com/luminus-framework/luminus-migrations/blob/master/src/luminus_migrations/core.clj#L65-L66:

    (if (= (count args) 1)
        (migratus/destroy config (first args))
        (migratus/destroy config))

It should be something like this:

      (if (> (count args) 1)
        (migratus/destroy config (second args))
        (migratus/destroy config))

There are no tests

An example of how to actually call the migrate function with the rollback and migrate arguments and some individual migration numbers would be useful.

That information does not appear to be in the docs, so both testing migrations and testing most db functions is extremely frustrating.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.