|
@ -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 <<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());" |
|
|
|
|
|
echo $include |
|
|
|
|
|
echo $map_entry |