using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Modules.User.Database.Migrations { /// public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "uuid", nullable: false), NickName = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), FirstName = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), Patronymic = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), LastName = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), AvatarId = table.Column(type: "uuid", nullable: true), RegionalSettings_LanguageId = table.Column(type: "uuid", nullable: true), Deleted = table.Column(type: "boolean", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "Accounts", columns: table => new { Id = table.Column(type: "uuid", nullable: false), UserId = table.Column(type: "uuid", nullable: false), Email = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), HashedPassword = table.Column(type: "text", nullable: false), CreationDate = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), Deleted = table.Column(type: "boolean", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Accounts", x => x.Id); table.ForeignKey( name: "FK_Accounts_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Sessions", columns: table => new { Id = table.Column(type: "uuid", nullable: false), RefreshToken = table.Column(type: "character varying(172)", maxLength: 172, nullable: false), ClientInfo_UserAgent = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), ClientInfo_Country = table.Column(type: "character varying(96)", maxLength: 96, nullable: true), ClientInfo_Region = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), ExpiredDate = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "'0001-01-01 00:00:00+00'"), LastUpdate = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), AccountId = table.Column(type: "uuid", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Sessions", x => x.Id); table.ForeignKey( name: "FK_Sessions_Accounts_AccountId", column: x => x.AccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Accounts_UserId", table: "Accounts", column: "UserId", unique: true); migrationBuilder.CreateIndex( name: "IX_Sessions_AccountId", table: "Sessions", column: "AccountId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Sessions"); migrationBuilder.DropTable( name: "Accounts"); migrationBuilder.DropTable( name: "Users"); } } }