python-3.xalembicdatabase-versioning

Create database using Alembic


I have database migrations that use database1. I'm using it for Alembic for migrations.

How do I create a database database1 before running alembic?

I've created a database infrastructure using CloudFormation. And when we run the first migration, I need to run SQL create database database1 or something equivalent.


Solution

  • I ended up using @SuperShoot's advice. I modified my CFT to include below snipppet

      "Parameters": {
        "DBName": {
          "Default": "<database name>",
          "Description": "The database name",
          "Type": "String",
          ...
        },
        ...
      }, 
      "Resources": {
       "RDSinstance": {
          "Type": "AWS::RDS::DBInstance",
          "Properties": {
            "DBName": {
              "Ref": "DBName"
            },
            ...
          }
        }, 
        ...
      }