You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#!/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 <<EOF > 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());" gawk -i inplace "FNR==NR{ if (/migrations.emplace/) p=NR; next} 1; FNR==p{ print \"$map_entry\" }" db/Schema.cpp db/Schema.cpp gawk -i inplace "FNR==NR{ if (/#include \"migrations/) p=NR; next} 1; FNR==p{ print \"$include\" }" db/Schema.cpp db/Schema.cpp
|