Skip to content

Instantly share code, notes, and snippets.

View takkaria's full-sized avatar

Anna Sidwell takkaria

  • @PeopleRetrofit
  • Berlin, DE
View GitHub Profile
@Jc2k
Jc2k / README.md
Last active July 22, 2024 21:26
Database rollback options in Django

Batching migrations

The idea here is that if you know which migrations were in version 2.0.3 of your project and which were in version 2.0.4 then setA - setB gives you the list of migrations you need to undo.

Django migrations give you a directed acyclic graph which describes how to get from the current database state to the target state. But there is no mechanism by which you can perform tasks like revert all the migrations that just ran in the last deployment.

Here is a quick recipe for batching Django migrations to allow you to do things like that.

Before you tag your project you do:

@branneman
branneman / better-nodejs-require-paths.md
Last active June 29, 2024 16:00
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions