{
  "databaseChangeLog": [
    {
      "changeSet": {
        "id": "Add addon_affected_units table",
        "author": "anibus",
        "changes": [
          {
            "createTable": {
              "tableName": "addon_affected_units",
              "columns": [
                {
                  "column": {
                    "name": "addon_id",
                    "type": "int",
                    "constraints": {
                      "nullable": false
                    }
                  }
                },
                {
                  "column": {
                    "name": "unit_id",
                    "type": "int",
                    "constraints": {
                      "nullable": false
                    }
                  }
                }
              ]
            }
          },
          {
            "addUniqueConstraint": {
              "columnNames": "addon_id, unit_id",
              "constraintName": "uc_addon_affected_units_addon_id_unit_id",
              "tableName": "addon_affected_units"
            }
          },
          {
            "addForeignKeyConstraint":
            {
              "baseColumnNames":  "addon_id",
              "baseTableName":  "addon_affected_units",
              "constraintName":  "fk_addon_addon_affected_units",
              "referencedColumnNames":  "id",
              "referencedTableName":  "building_addons",
              "onDelete": "CASCADE"
            }
          },
          {
            "addForeignKeyConstraint":
            {
              "baseColumnNames":  "unit_id",
              "baseTableName":  "addon_affected_units",
              "constraintName":  "fk_units_addon_affected_units",
              "referencedColumnNames":  "id",
              "referencedTableName":  "units",
              "onDelete": "CASCADE"
            }
          }
        ]
      }
    }
  ]
}
