Skip to content

Commit c81a39f

Browse files
fix: add migration for newsletter field
1 parent 93a6fc4 commit c81a39f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
use Emergence\People\User;
4+
5+
// skip conditions
6+
if (!static::tableExists(User::$tableName)) {
7+
printf("Skipping migration because table `%s` does not exist yet\n", User::$tableName);
8+
return static::STATUS_SKIPPED;
9+
}
10+
11+
if (static::columnExists(User::$tableName, 'Newsletter')) {
12+
printf("Skipping migration because column `Newsletter` in table `%s` already exists\n", User::$tableName);
13+
return static::STATUS_SKIPPED;
14+
}
15+
16+
17+
// migration
18+
printf("Adding `Newsletter` column to `%s` table\n", User::$tableName);
19+
DB::nonQuery('ALTER TABLE `%s` ADD `Newsletter` boolean NULL default 1', User::$tableName);
20+
21+
printf("Adding `Newsletter` column to `%s` table\n", User::$historyTable);
22+
DB::nonQuery('ALTER TABLE `%s` ADD `Newsletter` boolean NULL default 1', User::getHistoryTableName());
23+
24+
25+
// done
26+
return static::STATUS_EXECUTED;

0 commit comments

Comments
 (0)