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