Updated default values, added new init. migration

This commit is contained in:
Dennis Postma 2025-02-16 21:20:25 +01:00
parent b173a993f7
commit 58d7e02de2
3 changed files with 9 additions and 6 deletions

View File

@ -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

View File

@ -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": {

View File

@ -1,14 +1,14 @@
import { Migration } from '@mikro-orm/migrations';
export class Migration20250215152716 extends Migration {
export class Migration20250216202007 extends Migration {
override async up(): Promise<void> {
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\`);`);