using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Migrations; using NodaTime; #nullable disable namespace DysonNetwork.Sphere.Migrations { /// public partial class AddNotification : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterColumn( name: "picture_id", table: "publishers", type: "character varying(128)", nullable: true, oldClrType: typeof(string), oldType: "text", oldNullable: true); migrationBuilder.AlterColumn( name: "background_id", table: "publishers", type: "character varying(128)", nullable: true, oldClrType: typeof(string), oldType: "text", oldNullable: true); migrationBuilder.AlterColumn( name: "id", table: "files", type: "character varying(128)", maxLength: 128, nullable: false, oldClrType: typeof(string), oldType: "text"); migrationBuilder.AddColumn( name: "expired_at", table: "files", type: "timestamp with time zone", nullable: true); migrationBuilder.AlterColumn( name: "picture_id", table: "account_profiles", type: "character varying(128)", nullable: true, oldClrType: typeof(string), oldType: "text", oldNullable: true); migrationBuilder.AlterColumn( name: "background_id", table: "account_profiles", type: "character varying(128)", nullable: true, oldClrType: typeof(string), oldType: "text", oldNullable: true); migrationBuilder.CreateTable( name: "notification_push_subscriptions", columns: table => new { id = table.Column(type: "uuid", nullable: false), device_id = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: false), device_token = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: false), provider = table.Column(type: "integer", nullable: false), last_used_at = table.Column(type: "timestamp with time zone", nullable: true), account_id = table.Column(type: "bigint", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false), updated_at = table.Column(type: "timestamp with time zone", nullable: false), deleted_at = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("pk_notification_push_subscriptions", x => x.id); table.ForeignKey( name: "fk_notification_push_subscriptions_accounts_account_id", column: x => x.account_id, principalTable: "accounts", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "notifications", columns: table => new { id = table.Column(type: "uuid", nullable: false), title = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: true), subtitle = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true), content = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: true), meta = table.Column>(type: "jsonb", nullable: true), priority = table.Column(type: "integer", nullable: false), viewed_at = table.Column(type: "timestamp with time zone", nullable: true), account_id = table.Column(type: "bigint", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false), updated_at = table.Column(type: "timestamp with time zone", nullable: false), deleted_at = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("pk_notifications", x => x.id); table.ForeignKey( name: "fk_notifications_accounts_account_id", column: x => x.account_id, principalTable: "accounts", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "ix_notification_push_subscriptions_account_id", table: "notification_push_subscriptions", column: "account_id"); migrationBuilder.CreateIndex( name: "ix_notification_push_subscriptions_device_id", table: "notification_push_subscriptions", column: "device_id", unique: true); migrationBuilder.CreateIndex( name: "ix_notification_push_subscriptions_device_token", table: "notification_push_subscriptions", column: "device_token", unique: true); migrationBuilder.CreateIndex( name: "ix_notifications_account_id", table: "notifications", column: "account_id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "notification_push_subscriptions"); migrationBuilder.DropTable( name: "notifications"); migrationBuilder.DropColumn( name: "expired_at", table: "files"); migrationBuilder.AlterColumn( name: "picture_id", table: "publishers", type: "text", nullable: true, oldClrType: typeof(string), oldType: "character varying(128)", oldNullable: true); migrationBuilder.AlterColumn( name: "background_id", table: "publishers", type: "text", nullable: true, oldClrType: typeof(string), oldType: "character varying(128)", oldNullable: true); migrationBuilder.AlterColumn( name: "id", table: "files", type: "text", nullable: false, oldClrType: typeof(string), oldType: "character varying(128)", oldMaxLength: 128); migrationBuilder.AlterColumn( name: "picture_id", table: "account_profiles", type: "text", nullable: true, oldClrType: typeof(string), oldType: "character varying(128)", oldNullable: true); migrationBuilder.AlterColumn( name: "background_id", table: "account_profiles", type: "text", nullable: true, oldClrType: typeof(string), oldType: "character varying(128)", oldNullable: true); } } }