1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
use Phinx\Migration\AbstractMigration; |
|
|
|
|
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class CreateTokensTable |
9
|
|
|
*/ |
10
|
|
|
final class CreateSubscriptionsTable extends AbstractMigration |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Change Method. |
14
|
|
|
* |
15
|
|
|
* Write your reversible migrations using this method. |
16
|
|
|
* |
17
|
|
|
* More information on writing migrations is available here: |
18
|
|
|
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method |
19
|
|
|
* |
20
|
|
|
* Remember to call "create()" or "update()" and NOT "save()" when working |
21
|
|
|
* with the Table class. |
22
|
|
|
*/ |
23
|
|
|
public function change(): void |
24
|
|
|
{ |
25
|
|
|
$table_name = \ByTIC\Payments\Utility\PaymentsModels::subscriptions()->getTable(); |
26
|
|
|
$exists = $this->hasTable($table_name); |
27
|
|
|
if ($exists) { |
28
|
|
|
return; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
$table = $this->table($table_name) |
32
|
|
|
->addColumn('id_method', 'biginteger') |
33
|
|
|
->addColumn('id_token', 'biginteger') |
34
|
|
|
->addColumn('id_last_transaction', 'biginteger') |
35
|
|
|
->addColumn('customer_id', 'biginteger') |
36
|
|
|
->addColumn('customer_type', 'string') |
37
|
|
|
->addColumn('status', 'enum', ['values' => ['not_started', 'active', 'completed', 'canceled']]) |
38
|
|
|
->addColumn('billing_period', 'enum', ['values' => ['daily', 'weekly', 'monthly', 'yearly']]) |
39
|
|
|
->addColumn('billing_interval', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY]) |
|
|
|
|
40
|
|
|
->addColumn( |
41
|
|
|
'billing_count', |
42
|
|
|
'integer', |
43
|
|
|
['null' => true, 'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY] |
44
|
|
|
) |
45
|
|
|
->addColumn('start_at', 'date', ['null' => true]) |
46
|
|
|
->addColumn('cancel_at', 'date', ['null' => true]) |
47
|
|
|
->addColumn('ended_at', 'date', ['null' => true]) |
48
|
|
|
->addColumn('charge_at', 'date', ['null' => true]) |
49
|
|
|
->addColumn('charge_attempts', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY]) |
50
|
|
|
->addColumn( |
51
|
|
|
'charge_count', |
52
|
|
|
'integer', |
53
|
|
|
['null' => true, 'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY] |
54
|
|
|
) |
55
|
|
|
->addColumn('charge_method', 'string') |
56
|
|
|
->addColumn('metadata', 'json', ['null' => true]) |
57
|
|
|
->addColumn('modified', 'timestamp', [ |
58
|
|
|
'default' => 'CURRENT_TIMESTAMP', |
59
|
|
|
'update' => 'CURRENT_TIMESTAMP', |
60
|
|
|
]) |
61
|
|
|
->addColumn('created', 'timestamp', [ |
62
|
|
|
'default' => 'CURRENT_TIMESTAMP', |
63
|
|
|
]); |
64
|
|
|
|
65
|
|
|
$table->addIndex(['id_method']); |
66
|
|
|
$table->addIndex(['id_token']); |
67
|
|
|
$table->addIndex(['id_last_transaction']); |
68
|
|
|
$table->addIndex(['customer_id', 'customer_type']); |
69
|
|
|
$table->addIndex(['status']); |
70
|
|
|
$table->addIndex(['start_at']); |
71
|
|
|
$table->addIndex(['cancel_at']); |
72
|
|
|
$table->addIndex(['ended_at']); |
73
|
|
|
$table->addIndex(['charge_at']); |
74
|
|
|
|
75
|
|
|
$table->save(); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths