diff --git a/database/migrations/.snapshot-postgres.json b/database/migrations/.snapshot-postgres.json index 1e1adea..44a1442 100644 --- a/database/migrations/.snapshot-postgres.json +++ b/database/migrations/.snapshot-postgres.json @@ -1045,7 +1045,7 @@ "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "length": 255, "mappedType": "string" }, @@ -1055,7 +1055,7 @@ "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "length": 6, "mappedType": "datetime" }, @@ -1065,7 +1065,7 @@ "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "length": 6, "mappedType": "datetime" } diff --git a/database/migrations/Migration20260106054151.ts b/database/migrations/Migration20260106054151.ts new file mode 100644 index 0000000..96ead46 --- /dev/null +++ b/database/migrations/Migration20260106054151.ts @@ -0,0 +1,23 @@ +import { Migration } from '@mikro-orm/migrations'; + +export class Migration20260106054151 extends Migration { + + override async up(): Promise { + this.addSql(`alter table "restaurants" alter column "subscription_id" type varchar(255) using ("subscription_id"::varchar(255));`); + this.addSql(`alter table "restaurants" alter column "subscription_id" drop not null;`); + this.addSql(`alter table "restaurants" alter column "subscription_end_date" type timestamptz using ("subscription_end_date"::timestamptz);`); + this.addSql(`alter table "restaurants" alter column "subscription_end_date" drop not null;`); + this.addSql(`alter table "restaurants" alter column "subscription_start_date" type timestamptz using ("subscription_start_date"::timestamptz);`); + this.addSql(`alter table "restaurants" alter column "subscription_start_date" drop not null;`); + } + + override async down(): Promise { + this.addSql(`alter table "restaurants" alter column "subscription_id" type varchar(255) using ("subscription_id"::varchar(255));`); + this.addSql(`alter table "restaurants" alter column "subscription_id" set not null;`); + this.addSql(`alter table "restaurants" alter column "subscription_end_date" type timestamptz using ("subscription_end_date"::timestamptz);`); + this.addSql(`alter table "restaurants" alter column "subscription_end_date" set not null;`); + this.addSql(`alter table "restaurants" alter column "subscription_start_date" type timestamptz using ("subscription_start_date"::timestamptz);`); + this.addSql(`alter table "restaurants" alter column "subscription_start_date" set not null;`); + } + +} diff --git a/src/modules/restaurants/entities/restaurant.entity.ts b/src/modules/restaurants/entities/restaurant.entity.ts index f738be8..fa472be 100644 --- a/src/modules/restaurants/entities/restaurant.entity.ts +++ b/src/modules/restaurants/entities/restaurant.entity.ts @@ -100,13 +100,13 @@ export class Restaurant extends BaseEntity { @Enum(() => PlanEnum) plan: PlanEnum = PlanEnum.Base; - @Property({unique: true}) - subscriptionId!: string; + @Property({unique: true,nullable: true}) + subscriptionId?: string; - @Property() - subscriptionEndDate!: Date; + @Property({nullable: true}) + subscriptionEndDate?: Date; - @Property() - subscriptionStartDate!: Date; + @Property({nullable: true}) + subscriptionStartDate?: Date; }