Skip to content

Instantly share code, notes, and snippets.

@metric-space
Created June 10, 2019 20:30
Show Gist options
  • Save metric-space/3849048b19175de35c4632be7bdf426b to your computer and use it in GitHub Desktop.
Save metric-space/3849048b19175de35c4632be7bdf426b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os.path
import sys
import datetime
project_clj = "project.clj"
migration_directory = "resources/migrations"
def important_check_for_project():
return os.path.isfile("./"+ project_clj) and os.path.isdir("resources/migrations") and sys.argv[1]
if __name__ == '__main__':
if important_check_for_project():
filename = datetime.datetime.utcnow().strftime("%Y%m%d%M%S") + "-" + sys.argv[1]
up = filename + ".up.sql"
down = filename + ".down.sql"
open(os.path.join(migration_directory,up),"w+")
open(os.path.join(migration_directory,down),"w+")
else:
sys.stderr.write("Not doing anything because I am not in a clojure project root")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment