creatingElement static method

CreateStatement<DatabaseSchemaEntity> creatingElement(
  1. DatabaseSchemaEntity entity, {
  2. bool ifNotExists = false,
})

Returns a CreateStatement subclass suitable to create the given entity.

For tables, this would return a CreateTableStatement for example.

Implementation

static CreateStatement creatingElement(
  DatabaseSchemaEntity entity, {
  bool ifNotExists = false,
}) {
  return switch (entity) {
    GeneratedTable() => CreateTableStatement(
      entity,
      ifNotExists: ifNotExists,
    ),
    GeneratedView() => CreateViewStatement(entity, ifNotExists: ifNotExists),
    Trigger() => CreateTriggerStatement(entity, ifNotExists: ifNotExists),
    Index() => CreateIndexStatement(entity, ifNotExists: ifNotExists),
    _ => throw ArgumentError.value(
      entity,
      'entity',
      "Doesn't have a CREATE statement",
    ),
  };
}