Skip to content

REPL instructions in migrations.html not working #292

@winks

Description

@winks

To interactively create a new migration, https://luminusweb.com/docs/migrations.html tells you to do this:

(mount.core/start  #'<app>.db.core/*db*)
(user/create-migration "add-users-table")

I can not get this to work. Fresh sample project created this week via lein new luminus foobar +postgres, then adjusting :database-url in dev-config.edn, the db connection is known to work via lein run.

This is what I get:

$ cd foobar
$ lein repl

user=> (mount.core/start #'foobar.db.core/*db*)
Execution error (ClassCastException) at foobar.db.core/eval13540$fn (core.clj:14).
class mount.core.DerefableState cannot be cast to class clojure.lang.IFn (mount.core.DerefableState is in unnamed module of loader clojure.lang.DynamicClassLoader @57540fd0; clojure.lang.IFn is in unnamed module of loader 'app')

### this is the error that confuses me

user=> (user/start)
2021-12-30 09:48:46,579 [nREPL-session-b1f4b012-2cd9-4cfa-87a4-e9f735c8e430] ERROR luminus.http-server - server failed to start on port: 3000 
java.lang.RuntimeException: java.net.BindException: Address already in use

# this is not the problem, I know it's running, but I was playing around a bit

user=> (user/create-migration "foo" )
nil

### nothing happened

user=> (mount.core/start #'foobar.db.core/*db*)
{:started []}

### no more error

user=> (user/create-migration "change-something" )
nil

### still nothing happened

Also the line before the mount.start reads:

(defstate ^:dynamic *db*
  :start (conman/connect! {:jdbc-url (env :database-url)})
  :stop (conman/disconnect! *db*))

whereas in the code it is currently

(defstate ^:dynamic *db*
  :start (if-let [jdbc-url (env :database-url)]
           (conman/connect! {:jdbc-url jdbc-url})
           (do
             (log/warn "database connection URL was not found, please set :database-url in your config, e.g: dev-config.edn")
             *db*))
  :stop (conman/disconnect! *db*))

and I can't tell if that's a simplified version by default, or if it has changed meanwhile, or something else

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions