2
2
3
3
namespace Composite \Sync \Tests \Providers \MySQL ;
4
4
5
+ use Composite \DB \Traits \SoftDelete ;
6
+ use Composite \DB \Traits \UpdatedAt ;
5
7
use Composite \Sync \Attributes \SkipMigration ;
6
8
use Composite \DB \Attributes \{PrimaryKey , Table };
7
9
use Composite \Sync \Providers \MySQL \MySQLComparator ;
@@ -38,6 +40,8 @@ public function __construct(
38
40
#[Index(columns: ['name ' ], isUnique: true )]
39
41
#[Index(columns: ['name ' , 'created_at ' ])]
40
42
class (1 , 'Test ' ) extends AbstractEntity {
43
+ use UpdatedAt;
44
+ use SoftDelete;
41
45
public function __construct (
42
46
#[PrimaryKey]
43
47
public readonly int $ id ,
@@ -132,7 +136,7 @@ public function __construct(
132
136
[
133
137
'entity ' => $ entityWithIndex ,
134
138
'sql ' => null ,
135
- 'expectedNewColumns ' => ['id ' , 'name ' , 'created_at ' ],
139
+ 'expectedNewColumns ' => ['id ' , 'name ' , 'created_at ' , ' updated_at ' , ' deleted_at ' ],
136
140
'expectedChangedColumns ' => [],
137
141
'expectedNewIndexes ' => [
138
142
new MySQLIndex (
@@ -156,6 +160,8 @@ public function __construct(
156
160
`id` INT NOT NULL,
157
161
`name` VARCHAR(255) NOT NULL,
158
162
`created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
163
+ `updated_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
164
+ `deleted_at` TIMESTAMP(6) NULL DEFAULT NULL,
159
165
PRIMARY KEY (`id`),
160
166
UNIQUE KEY `FooI_unq_name` (`name`),
161
167
KEY `FooI_idx_name_created_at` (`name`,`created_at`)
@@ -173,6 +179,8 @@ public function __construct(
173
179
`id` INT NOT NULL,
174
180
`name` VARCHAR(255) NOT NULL,
175
181
`created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
182
+ `updated_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
183
+ `deleted_at` TIMESTAMP(6) NULL DEFAULT NULL,
176
184
PRIMARY KEY (`id`),
177
185
UNIQUE KEY `FooI_unq_name` (`name`),
178
186
KEY `FooI_idx_name_created_at` (`name`,`created_at`)
@@ -193,6 +201,8 @@ public function __construct(
193
201
`id` INT NOT NULL,
194
202
`name` VARCHAR(255) NOT NULL,
195
203
`created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
204
+ `updated_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
205
+ `deleted_at` TIMESTAMP(6) NULL DEFAULT NULL,
196
206
PRIMARY KEY (`name`),
197
207
KEY `FooI_idx_created_at` (`created_at`)
198
208
) ENGINE=InnoDB COLLATE=utf8mb4_unicode_ci;
@@ -242,6 +252,8 @@ public function __construct(
242
252
`id` INT NOT NULL,
243
253
`name` VARCHAR(128) NOT NULL,
244
254
`created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
255
+ `updated_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
256
+ `deleted_at` TIMESTAMP(6) NULL DEFAULT NULL,
245
257
PRIMARY KEY (`id`),
246
258
UNIQUE KEY `FooI_unq_name` (`name`),
247
259
KEY `FooI_idx_created_name_at` (`created_at`, `name`)
0 commit comments