Fork me on GitHub
#beginners
<
2020-12-07
>
scythx00:12:40

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.

Evan Bowling04:12:31

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
seancorfield05:12:57

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
seancorfield05:12:23

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
seancorfield05:12:24

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
scythx06:12:30

Okay, thank you everyone! now i understand better!

okwori06:12:11

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

wactbprot09:12:06

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

Abraham Palmer14:12:24

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.

Sam Stowers17:12:28

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

Abraham Palmer11:12:31

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.

mashimom21:12:23

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

hiredman21:12:17

::name doesn't exist

hiredman21:12:01

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

hiredman21:12:24

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

mashimom21:12:42

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

dpsutton21:12:54

evaluate ::name in a repl

hiredman21:12:05

this is going to go places

😂 1
mashimom21:12:28

:mynamespace/name

hiredman21:12:33

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

hiredman21:12:05

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

1
hiredman21:12:39

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

mashimom21:12:56

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

alexmiller21:12:22

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

hiredman21:12:25

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

mashimom21:12:54

ok, thanks!

hiredman21:12:22

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

ghadi21:12:15

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

hiredman21:12:14

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

alexmiller21:12:35

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

❤️ 2
mashimom22:12:47

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