beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
scythx 2020-12-07T00:46:40.058Z

Hello, i don't really understand with the concept of 'migration'. As far as i know, i have to put query to create table in up file and drop table in down file. But how about the data? do i have to backup and create script to re-insert all data when i have new version of the schema? I'm using migratus atm.

2020-12-07T04:25:31.066600Z

Personally I wouldn’t script the creation of data rows unless they were minimal and had a very specific set of required values. While schema migrations support incremental development, they don’t fully replace standard db backup/restore processes Here’s a link that may help: https://en.wikipedia.org/wiki/Schema_migration

❤️ 1
seancorfield 2020-12-07T05:00:57.066900Z

At work, we're up to about 860 migrations now, from an empty database to the current production setup. When you change the schema, you have two choices: 1) make changes in a strictly backward-compatible manner (e.g., adding nullable columns, adding columns with defaults) or 2) use specific scripted manually-applied schema/data migrations to do more complex things.

❤️ 1
seancorfield 2020-12-07T05:05:23.067100Z

Sometimes, your tables are too large in production to be able to just run automated migrations that modify the schema. Sometimes you have to get very creative, creating new versions of tables, swapping them atomically in production, and then backfilling the new table from the old -- and dealing with any weirdness that may cause your applications. Sometimes you can't even do that and, instead, you need to create a new table and also update your code to conditional work on the new table or the old table while it migrates data on demand and then backfills.

❤️ 1
seancorfield 2020-12-07T05:10:24.067300Z

All that said, in practice for most migrations, you are creating new tables or you're working with small enough databases that most schema operations are "safe" 🙂

❤️ 1
scythx 2020-12-07T06:01:30.067900Z

Okay, thank you everyone! now i understand better!

okwori 2020-12-07T06:08:11.069700Z

I have seen this used within cljs hiccup code a few times, not sure what it means [:<> ...

saitouena 2020-12-07T06:16:56.069800Z

It's a reagent specific thing to use React Fragment feature. https://github.com/reagent-project/reagent/blob/master/doc/ReactFeatures.md#fragments

👍 1
wactbprot 2020-12-07T09:03:49.076100Z

Hello, I got a Clojure Java interop question and hope this is the right place. Given the class

public class VXI11Factory {
    /**
     * Create a VXI11Controller.
     * @param hostName The hostName or INET address.
     * @param vxiName The VXI name.
     * @return The interface for the VXI11Controller.
     */
    public static VXI11Controller create(String hostName,String vxiName){
        Controller controller = new Controller(hostName,vxiName);
        return controller;
    }
  ...
I want to create a VXI controller by (.create (VXI11Factory.) "host" "dev") but receive No matching method create found taking 2 args for class jvxi11.VXI11Factory The (:import [jvxi11 VXI11Factory VXI11UserFactory VXI11Controller])) seems to work and I got no idea where to start. Can someone point to a search direction, thank you!

wactbprot 2020-12-07T09:11:06.077100Z

Forgot a link: I try to access this lib: http://github.com/mikef5410/jvxi11

Timur Latypoff 2020-12-07T09:12:46.077200Z

You're trying to access a static method as a member. Try this instead: (VXI11Factory/create "host" "dev")

💯 1
Timur Latypoff 2020-12-07T09:13:58.077500Z

The static method does not belong to any instance, so you just run it directly with this syntax (ClassName/staticMethod ...)

wactbprot 2020-12-07T09:17:15.077800Z

Great! Thank you very much!

👍 1
2020-12-07T14:18:24.084700Z

I mostly run https://boxturtlebakery.com/ these days, but started learning Clojure last week to work on some hobby projects. As a hobbyist I really appreciate a broad scope of a few tools so that building my application doesn't require me to put a dozen new things on my stack and holds up well over time. My current bakery application running some Python on Google's AppEngine has really only been updated once in 10 years so I don't want to spend a lot of time upgrading just to upgrade. I'm interested in building peer-to-peer applications on the cryptographically secure distributed database/platform https://holochain.org/. I'll need some Clojure for utilities and maybe even a desktop app and maybe a few small services and then ClojureScript for some SPA's. I might also need a local database to pull together for efficient searching multiple datasets in Holochain. Let me know if you are on a similar path or have suggestions for the journey.

2020-12-08T11:14:31.128300Z

Yes, I actually just saw a talk on that at re:Clojure and the author said "yes, you could use a different database. there would be significant work involved, particularly with implementing query subscriptions. But a while ago someone was experimenting with using datomic instead of crux, and I've structured the code to facilitate swapping out the db". Definitely worth digging into.

Sam Stowers 2020-12-07T17:13:28.085900Z

Have you seen Clojure Biff? It's new but could help you take care of several of the above in one swoop

mashimom 2020-12-07T21:45:23.088200Z

Hi, When I call (keyword "name") I get :name. How do I get ::name for a string "name"?

2020-12-07T21:46:17.088500Z

::name doesn't exist

2020-12-07T21:47:01.089200Z

::name is syntax, that when read depending on the context can be come any number of values

2020-12-07T21:47:24.090Z

there is single value that is ::name that prints as ::name

mashimom 2020-12-07T21:47:42.090400Z

Right, ::name is name keyword on current namespace, correct?

dpsutton 2020-12-07T21:47:54.090600Z

evaluate ::name in a repl

2020-12-07T21:48:05.090900Z

this is going to go places

😂 1
mashimom 2020-12-07T21:48:28.091600Z

:mynamespace/name

2020-12-07T21:48:33.091800Z

"current namespace" is the binding of the dynamic var *ns*

2020-12-07T21:49:05.092500Z

that only has a meaningful value when code is being read and compiled

➕ 1
2020-12-07T21:49:39.093700Z

generally while code is executing *ns* can be anything entirely unreleated to whatever code is executing

mashimom 2020-12-07T21:49:56.094400Z

clojure spec asks me to create specs as ::name, which means my maps need keys ::name, while :name fails

alexmiller 2020-12-07T21:50:22.095400Z

clojure spec does not ask you to do that, you can use any keyword you like

2020-12-07T21:50:25.095600Z

the spec docs use :: for brevity, not because you have to

alexmiller 2020-12-07T21:50:48.096200Z

☝️

mashimom 2020-12-07T21:50:54.096500Z

ok, thanks!

2020-12-07T21:51:22.097Z

some disagree, but I recommend avoiding using :: at all, because it makes things very context dependent

ghadi 2020-12-07T21:52:15.098600Z

*any namespace qualified keyword :foo/bar OR ::bar BUT NOT :bar (not qualified)

mashimom 2020-12-07T21:52:37.098900Z

got it

mashimom 2020-12-07T21:52:48.099200Z

thanks!

2020-12-07T21:59:14.102600Z

for the current namespace thing, which is maybe moot now, but something to know and keep in mind is that a clojure namespace is not like a class, there is no "this" pointer or whatever. a function is a value that could be named in multiple namespaces, and it doesn't have a pointer to the whatever the current namespace was when it was compiled

alexmiller 2020-12-07T21:59:35.102700Z

there is a block in the spec guide that talks about this. I pushed a change to make that a bit more prominent

❤️ 2
mashimom 2020-12-07T22:20:47.103800Z

The non-compile time namespace binding I knew about. But it makes sense. Thanks!