Skip to content

lein run :duct/migrator doesn't work #5

Open

Description

@rynkowsg

I'm following the GUIDE.rst. I'm at the migrations section at the moment. Migrations seems to work flawlessly from REPL but I noticed that the command from Running Database Migrations in Production doesn't work.

I got error:

$ lein run :duct/migrator                                                                                                   !10041
Exception in thread "main" Syntax error compiling at (/private/var/folders/5y/8ds1f60x1mx9xcqx61hw_6w00000gn/T/form-init4783091540319585709.clj:1:125).
Error on key :duct.database.sql/hikaricp when building system
        at clojure.lang.Compiler.load(Compiler.java:7647)
        at clojure.lang.Compiler.loadFile(Compiler.java:7573)
        at clojure.main$load_script.invokeStatic(main.clj:452)
        at clojure.main$init_opt.invokeStatic(main.clj:454)
        at clojure.main$init_opt.invoke(main.clj:454)
        at clojure.main$initialize.invokeStatic(main.clj:485)
        at clojure.main$null_opt.invokeStatic(main.clj:519)
        at clojure.main$null_opt.invoke(main.clj:516)
        at clojure.main$main.invokeStatic(main.clj:598)
        at clojure.main$main.doInvoke(main.clj:561)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.main.main(main.java:37)
Caused by: clojure.lang.ExceptionInfo: Error on key :duct.database.sql/hikaricp when building system {:reason :integrant.core/build-threw-exception, :system {
:duct.logger.timbre/println {:enabled? true, :async? false, :min-level nil, :rate-limit nil, :output-fn :inherit, :fn #object[taoensso.timbre.appenders.core$p
rintln_appender$fn__4380 0x2474331d "taoensso.timbre.appenders.core$println_appender$fn__4380@2474331d"]}, :duct.logger/timbre #duct.logger.timbre.TimbreLogge
r{:config {:level :info, :appenders {:duct.logger.timbre/println {:enabled? true, :async? false, :min-level nil, :rate-limit nil, :output-fn :inherit, :fn #ob
ject[taoensso.timbre.appenders.core$println_appender$fn__4380 0x2474331d "taoensso.timbre.appenders.core$println_appender$fn__4380@2474331d"]}}}}}, :function
#object[clojure.lang.MultiFn 0x46977829 "clojure.lang.MultiFn@46977829"], :key :duct.database.sql/hikaricp, :value {:jdbc-url nil, :logger #duct.logger.timbre
.TimbreLogger{:config {:level :info, :appenders {:duct.logger.timbre/println {:enabled? true, :async? false, :min-level nil, :rate-limit nil, :output-fn :inhe
rit, :fn #object[taoensso.timbre.appenders.core$println_appender$fn__4380 0x2474331d "taoensso.timbre.appenders.core$println_appender$fn__4380@2474331d"]}}}}}
}
        at integrant.core$build_exception.invokeStatic(core.cljc:283)
        at integrant.core$build_exception.invoke(core.cljc:282)
        at integrant.core$try_build_action.invokeStatic(core.cljc:294)
        at integrant.core$try_build_action.invoke(core.cljc:291)
        at integrant.core$build_key.invokeStatic(core.cljc:300)
        at integrant.core$build_key.invoke(core.cljc:296)
        at clojure.core$partial$fn__5826.invoke(core.clj:2632)
        at clojure.core.protocols$fn__8144.invokeStatic(protocols.clj:168)
        at clojure.core.protocols$fn__8144.invoke(protocols.clj:124)
        at clojure.core.protocols$fn__8099$G__8094__8108.invoke(protocols.clj:19)
        at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:31)
        at clojure.core.protocols$fn__8131.invokeStatic(protocols.clj:75)
        at clojure.core.protocols$fn__8131.invoke(protocols.clj:75)
        at clojure.core.protocols$fn__8073$G__8068__8086.invoke(protocols.clj:13)
        at clojure.core$reduce.invokeStatic(core.clj:6828)
        at clojure.core$reduce.invoke(core.clj:6810)
        at integrant.core$build.invokeStatic(core.cljc:321)
        at integrant.core$build.invoke(core.cljc:303)
        at integrant.core$init.invokeStatic(core.cljc:418)
        at integrant.core$init.invoke(core.cljc:410)
        at duct.core$exec_config.invokeStatic(core.clj:225)
        at duct.core$exec_config.invoke(core.clj:213)
        at todo.main$_main.invokeStatic(main.clj:12)
        at todo.main$_main.doInvoke(main.clj:7)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.lang.Var.invoke(Var.java:384)
        at user$eval151.invokeStatic(form-init4783091540319585709.clj:1)
        at user$eval151.invoke(form-init4783091540319585709.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:7176)
        at clojure.lang.Compiler.eval(Compiler.java:7166)
        at clojure.lang.Compiler.load(Compiler.java:7635)
        ... 12 more
Caused by: java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required.
        at com.zaxxer.hikari.HikariConfig.validate(HikariConfig.java:955)
        at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:77)
        at hikari_cp.core$make_datasource.invokeStatic(core.clj:251)
        at hikari_cp.core$make_datasource.invoke(core.clj:248)
        at duct.database.sql.hikaricp$eval5348$fn__5350.invoke(hikaricp.clj:45)
        at clojure.lang.MultiFn.invoke(MultiFn.java:234)
        at integrant.core$try_build_action.invokeStatic(core.cljc:292)
        ... 40 more

I understand the problem, though, I'm not sure how should I specify data source or jdbc url from the command line.

I noticed that in the error log the :duct.database.sql/hikaricp keyword is missing. Once I added:

:duct.database.sql/hikaricp {:jdbc-url nil,
                             :logger #ig/ref :duct/logger,
                             :connection-uri "jdbc:sqlite:db/dev.sqlite"}

to the config.edn the command lein run :duct/migrator works fine.

If this is the right solution for this issue, I can add a minor comment that the command requires definition of :duct.database.sql/hikaricp. If not, am I missing something?

Activity

  1. changed the title [-]The example of running migration in production[/-] [+]`lein run :duct/migrator` doesn't work[/+] on Jun 25, 2019
  2. weavejester commented on Jun 25, 2019

    @weavejester
    Contributor

    It looks like I forgot to explain in the guide that Duct uses the JDBC_DATABASE_URL or DATABASE_URL variables by default. In production, it's recommended to use these constants, though you can also grab the database URL from any source you want.

  3. rynkowsg commented on Jun 28, 2019

    @rynkowsg
    Author

    Ok, make sense now. It works with the given variables.

    I'm closing this issue now. I can also update the doc if you want.

  4. weavejester commented on Jun 28, 2019

    @weavejester
    Contributor

    I'm going to reopen this issue to remind me to add an explanation of the database variables. If you want to also submit a PR to add that information yourself, please feel free.

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

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