diff --git a/src/entities/base/mapEventTile.ts b/src/entities/base/mapEventTile.ts index afc8e70..9b85382 100644 --- a/src/entities/base/mapEventTile.ts +++ b/src/entities/base/mapEventTile.ts @@ -17,10 +17,10 @@ export class BaseMapEventTile extends BaseEntity { type!: MapEventTileType @Property() - positionX!: number + positionX: number = 0 @Property() - positionY!: number + positionY: number = 0 @OneToOne({ eager: true }) teleport?: MapEventTileTeleport diff --git a/src/migrations/.snapshot-game.json b/src/migrations/.snapshot-game.json index 3a6735c..1ab2576 100644 --- a/src/migrations/.snapshot-game.json +++ b/src/migrations/.snapshot-game.json @@ -21,6 +21,7 @@ "primary": false, "nullable": false, "length": 255, + "default": "''", "mappedType": "string" }, "width": { @@ -51,7 +52,7 @@ "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "length": null, "mappedType": "json" }, @@ -233,6 +234,7 @@ "primary": false, "nullable": false, "length": null, + "default": "0", "mappedType": "integer" }, "position_y": { @@ -243,6 +245,7 @@ "primary": false, "nullable": false, "length": null, + "default": "0", "mappedType": "integer" }, "teleport_id": { diff --git a/src/migrations/Migration20250215152716.ts b/src/migrations/Migration20250216202007.ts similarity index 96% rename from src/migrations/Migration20250215152716.ts rename to src/migrations/Migration20250216202007.ts index 49e2473..3e3571b 100644 --- a/src/migrations/Migration20250215152716.ts +++ b/src/migrations/Migration20250216202007.ts @@ -1,14 +1,14 @@ import { Migration } from '@mikro-orm/migrations'; -export class Migration20250215152716 extends Migration { +export class Migration20250216202007 extends Migration { override async up(): Promise { - this.addSql(`create table \`map\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`width\` int not null default 10, \`height\` int not null default 10, \`tiles\` json null, \`pvp\` tinyint(1) not null default false, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`); + this.addSql(`create table \`map\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null default '', \`width\` int not null default 10, \`height\` int not null default 10, \`tiles\` json not null, \`pvp\` tinyint(1) not null default false, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`); this.addSql(`create table \`map_effect\` (\`id\` varchar(255) not null, \`map_id\` varchar(255) not null, \`effect\` varchar(255) not null, \`strength\` int not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`); this.addSql(`alter table \`map_effect\` add index \`map_effect_map_id_index\`(\`map_id\`);`); - this.addSql(`create table \`map_event_tile\` (\`id\` varchar(255) not null, \`map_id\` varchar(255) not null, \`type\` enum('BLOCK', 'TELEPORT', 'NPC', 'ITEM') not null, \`position_x\` int not null, \`position_y\` int not null, \`teleport_id\` varchar(255) null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`); + this.addSql(`create table \`map_event_tile\` (\`id\` varchar(255) not null, \`map_id\` varchar(255) not null, \`type\` enum('BLOCK', 'TELEPORT', 'NPC', 'ITEM') not null, \`position_x\` int not null default 0, \`position_y\` int not null default 0, \`teleport_id\` varchar(255) null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`); this.addSql(`alter table \`map_event_tile\` add index \`map_event_tile_map_id_index\`(\`map_id\`);`); this.addSql(`alter table \`map_event_tile\` add unique \`map_event_tile_teleport_id_unique\`(\`teleport_id\`);`);