1

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.

Ganesh Satpute
  • 3,664
  • 6
  • 41
  • 78
  • 1
    For many backends, if you define `DBName` property on the resource CloudFormation will create the database for you: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html. As you haven’t mentioned the flavor of database you are using I can’t know whether this is helpful advice for you or not. – SuperShoot Oct 24 '19 at 11:35
  • I'll have a look at this. Just FYI, I'm using RDS with MySQL. – Ganesh Satpute Oct 24 '19 at 12:14

1 Answers1

0

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"
        },
        ...
      }
    }, 
    ...
  }

Ganesh Satpute
  • 3,664
  • 6
  • 41
  • 78