using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ClassNotify.Server.Data.Migrations
{
///
public partial class AddDeviceLicenseLifecycle : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "LicensedUntil",
table: "Devices",
type: "timestamp with time zone",
nullable: true);
migrationBuilder.AddColumn(
name: "LicenseTier",
table: "Devices",
type: "text",
nullable: false,
defaultValue: "Trial");
migrationBuilder.AddColumn(
name: "TrialUsed",
table: "Devices",
type: "boolean",
nullable: false,
defaultValue: true);
migrationBuilder.AddColumn(
name: "LicenseDurationDays",
table: "ActivationCodes",
type: "integer",
nullable: true,
defaultValue: 7);
migrationBuilder.AddColumn(
name: "LicenseTier",
table: "ActivationCodes",
type: "text",
nullable: false,
defaultValue: "Trial");
migrationBuilder.CreateTable(
name: "DeviceLicenses",
columns: table => new
{
Id = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
TenantId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
DeviceId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
ClassroomId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
Action = table.Column(type: "character varying(50)", maxLength: 50, nullable: false),
LicenseTier = table.Column(type: "character varying(50)", maxLength: 50, nullable: false),
GrantedDays = table.Column(type: "integer", nullable: true),
PreviousLicensedUntil = table.Column(type: "timestamp with time zone", nullable: true),
NewLicensedUntil = table.Column(type: "timestamp with time zone", nullable: true),
SourceActivationCode = table.Column(type: "character varying(100)", maxLength: 100, nullable: true),
OperatorUsername = table.Column(type: "character varying(100)", maxLength: 100, nullable: true),
Reason = table.Column(type: "character varying(250)", maxLength: 250, nullable: true),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceLicenses", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_DeviceLicenses_TenantId_DeviceId",
table: "DeviceLicenses",
columns: new[] { "TenantId", "DeviceId" });
migrationBuilder.CreateIndex(
name: "IX_DeviceLicenses_CreatedAt",
table: "DeviceLicenses",
column: "CreatedAt");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DeviceLicenses");
migrationBuilder.DropColumn(
name: "LicensedUntil",
table: "Devices");
migrationBuilder.DropColumn(
name: "LicenseTier",
table: "Devices");
migrationBuilder.DropColumn(
name: "TrialUsed",
table: "Devices");
migrationBuilder.DropColumn(
name: "LicenseDurationDays",
table: "ActivationCodes");
migrationBuilder.DropColumn(
name: "LicenseTier",
table: "ActivationCodes");
}
}
}