w3c / mnx

Music Notation CG next-generation music markup proposal.
179 stars 18 forks source link

Docgenerator loaddb/freezedb safety #350

Closed mscuthbert closed 2 months ago

mscuthbert commented 3 months ago

Since the sqllite file isn't committed to disk and doesn't change as branches change, but the m[usic|n]x(ml)?.json file does change with each branch change, I've found myself needing to be paranoid about whether I'm overwriting an older version of .json or of .sqllite with my loaddb/freezedb commands.

I wanted to propose that the spec.manangement.commands.freezedb/loaddb files check the timestamp of the .json file vs. the .sqllite file, and if the one being overridden is newer than the one being written from, that there would be a prompt asking for permission before doing so.

I was going to implement this on my own, but I realized quickly that I've never used Django with an sqllite db, so I couldn't figure out how to get the modified time of the database. If you agree that this would be useful, you can just send me the code to find the sqllite file (from within a management command) and I can probably write the rest quite easily.

Thanks!

adrianholovaty commented 3 months ago

I agree there's a bit of a uneasy, "playing with fire" feeling with the docs system whenever multiple branches are at play.

Checking the DB timestamp might be worth doing, but for some reason that gives me the feeling of addressing a symptom rather than the core problem. I can't articulate why.

Would it help to have a command that compares the local state of the DB with the local JSON file, and displays a diff?

mscuthbert commented 3 months ago

That would help, but I think the most important thing would be to prevent overwriting (without confirmation) in either direction w/o checking the time.

Because the .json file is committed to git, overwriting it is actually less of a disaster than the other way around.

(I'd like to make some other changes to the docgenerator which I'm realizing is most helpful for my working methods, such as not keeping the static files in the DB itself, just a reference to the filename -- I'm wondering if forking the docgenerator repo into MNX and MusicXML versions would be best given that there are now XML and JSON technologies?)

mscuthbert commented 2 months ago

Closing and moving to the new w3c-cg/mnxdocgenerator Repo.