You can use `lein run` to execute a function from your project while
avoiding the complexity/distribution of a plugin.

In order to seed from a command line I would::
1. Write a function that can seed the data (like the blog post).
2. Use `lein run -m my.seed.ns/load-fixtures`.  This will start a jvm with
all your project deps and then run the specified function.
3. Add an alias to the project.clj by adding `:aliases {"seed" ["run" "-m"
"my.seed.ns/load-fixtures"]}`.  This allows the above command to be run
using `lein seed`, which is easier to remember.


On Sat, Jul 26, 2014 at 8:50 AM, Rui Yang <ryang....@gmail.com> wrote:

> Hi all,
>
> Using Leiningen, wonder what is the best way of seeding my database.
>
> I used ragtime to do the migration. I could drop the database and recreate
> it. After creating database, I would like to invoke some task to seed my
> database.
>
> One approach could be
> http://dustingetz.tumblr.com/post/24982262733/clojure-webapp-fixtures-seed-data.
> It needs to manually specify the relation of entity, eg set the ID of the
> entity, and foreign key of the entity. When the ID is auto-generated in
> database, you may not be able to set the id manually.
>
> Ideally, I could just write a function to read the yaml fixture, and call
> my functions based on korma to seed data. But I don't know how to do it.
> Could a Leiningen plugin to call the functions in the project?
>
> Wonder if anyone has a better idea?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to