Skip to content

Commit

Permalink
Only add table if not exists
Browse files Browse the repository at this point in the history
This is helpful to upgrade testers & also to sites that want to pre-add tables
  • Loading branch information
eileenmcnaughton committed Jun 20, 2024
1 parent 9c1e82d commit e8ff4cb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mixin/lib/civimix-schema/src/SqlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getDropTablesSql(): string {
public function generateCreateTableWithConstraintSql(array $entity): string {
$definition = $this->getTableDefinition($entity);
$constraints = $this->getTableConstraints($entity);
$sql = "CREATE TABLE `{$entity['table']}` (\n " .
$sql = "CREATE TABLE IF NOT EXISTS `{$entity['table']}` (\n " .
implode(",\n ", $definition);
if ($constraints) {
$sql .= ",\n " . implode(",\n ", $constraints);
Expand Down

0 comments on commit e8ff4cb

Please sign in to comment.