luminus-framework / luminus-migrations Goto Github PK
View Code? Open in Web Editor NEWMigrations library for Luminus
License: Eclipse Public License 1.0
Migrations library for Luminus
License: Eclipse Public License 1.0
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:
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.
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!
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!
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.
Can we use the latest and greatest from: https://github.com/yogthos/migratus?
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))
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.