From e0bc912db1064ec94db13740239750fadb388c5f Mon Sep 17 00:00:00 2001 From: Stefan Pranger Date: Mon, 28 Jun 2021 18:05:08 +0200 Subject: [PATCH] added script for creation of migrations --- create_migration.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 create_migration.sh diff --git a/create_migration.sh b/create_migration.sh new file mode 100755 index 0000000..911a630 --- /dev/null +++ b/create_migration.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +epoch="$(date +%s)" +[ -f $1 ] && echo "Please provide a name for the migration" && exit 1 +migration_name=$1 +migration=${epoch}_${migration_name} + +$(cat < db/migrations/$migration.h +#pragma once + +namespace db { + namespace migrations { + namespace db_builder = db::migrations::builder; + + class m$migration : public Migration { + public: + m$migration() : Migration() { + db_builder::Table $migration_name = db_builder::Table:: + + m_statement = $migration_name.str(); + } + }; + } +} +EOF +) + +include="#include \"migrations/$migration.h\"" +map_entry="migrations.emplace($epoch, new db::migrations::m$migration());" +echo $include +echo $map_entry