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.

31 lines
688 B

  1. #!/bin/sh
  2. epoch="$(date +%s)"
  3. [ -f $1 ] && echo "Please provide a name for the migration" && exit 1
  4. migration_name=$1
  5. migration=${epoch}_${migration_name}
  6. $(cat <<EOF > db/migrations/$migration.h
  7. #pragma once
  8. namespace db {
  9. namespace migrations {
  10. namespace db_builder = db::migrations::builder;
  11. class m$migration : public Migration {
  12. public:
  13. m$migration() : Migration() {
  14. db_builder::Table $migration_name = db_builder::Table::
  15. m_statement = $migration_name.str();
  16. }
  17. };
  18. }
  19. }
  20. EOF
  21. )
  22. include="#include \"migrations/$migration.h\""
  23. map_entry="migrations.emplace($epoch, new db::migrations::m$migration());"
  24. echo $include
  25. echo $map_entry