diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index cd967fc..0000000 --- a/.dockerignore +++ /dev/null @@ -1,25 +0,0 @@ -**/.dockerignore -**/.env -**/.git -**/.gitignore -**/.project -**/.settings -**/.toolstarget -**/.vs -**/.vscode -**/.idea -**/*.*proj.user -**/*.dbmdl -**/*.jfm -**/azds.yaml -**/bin -**/charts -**/docker-compose* -**/Dockerfile* -**/node_modules -**/npm-debug.log -**/obj -**/secrets.dev.yaml -**/values.dev.yaml -LICENSE -README.md \ No newline at end of file diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 6fb47de..0000000 --- a/.gitattributes +++ /dev/null @@ -1,10 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto -Moonlight/wwwroot/** linguist-vendored -Moonlight/wwwroot/assets/js/scripts.bundle.js linguist-vendored -Moonlight/wwwroot/assets/js/widgets.bundle.js linguist-vendored -Moonlight/wwwroot/assets/js/theme.js linguist-vendored -Moonlight/wwwroot/assets/css/boxicons.min.css linguist-vendored -Moonlight/wwwroot/assets/css/style.bundle.css linguist-vendored -Moonlight/wwwroot/assets/plugins/** linguist-vendored -Moonlight/wwwroot/assets/fonts/** linguist-vendored diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e836232..0000000 --- a/.gitignore +++ /dev/null @@ -1,44 +0,0 @@ - Common IntelliJ Platform excludes - -# User specific -**/.idea/**/workspace.xml -**/.idea/**/tasks.xml -**/.idea/shelf/* -**/.idea/dictionaries -**/.idea/httpRequests/ - -# Sensitive or high-churn files -**/.idea/**/dataSources/ -**/.idea/**/dataSources.ids -**/.idea/**/dataSources.xml -**/.idea/**/dataSources.local.xml -**/.idea/**/sqlDataSources.xml -**/.idea/**/dynamic.xml - -# Rider -# Rider auto-generates .iml files, and contentModel.xml -**/.idea/**/*.iml -**/.idea/**/contentModel.xml -**/.idea/**/modules.xml - - -Moonlight/[Bb]in/ -Moonlight/[Oo]bj/ -Moonlight/_UpgradeReport_Files/ -Moonlight/[Pp]ackages/ - -*.suo -*.user -.vs/ -[Bb]in/ -[Oo]bj/ -_UpgradeReport_Files/ -[Pp]ackages/ - -Thumbs.db -Desktop.ini -.DS_Store -.idea/.idea.Moonlight/.idea/discord.xml -Moonlight/wwwroot/css/theme.css -Moonlight/wwwroot/css/theme.css.map -storage/ diff --git a/.idea/.idea.Moonlight/.idea/efCoreCommonOptions.xml b/.idea/.idea.Moonlight/.idea/efCoreCommonOptions.xml deleted file mode 100644 index c001b75..0000000 --- a/.idea/.idea.Moonlight/.idea/efCoreCommonOptions.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/.idea.Moonlight/.idea/efCoreDialogsState.xml b/.idea/.idea.Moonlight/.idea/efCoreDialogsState.xml deleted file mode 100644 index 8f682f3..0000000 --- a/.idea/.idea.Moonlight/.idea/efCoreDialogsState.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/.idea.Moonlight/.idea/encodings.xml b/.idea/.idea.Moonlight/.idea/encodings.xml deleted file mode 100644 index df87cf9..0000000 --- a/.idea/.idea.Moonlight/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/.idea.Moonlight/.idea/indexLayout.xml b/.idea/.idea.Moonlight/.idea/indexLayout.xml deleted file mode 100644 index 7b08163..0000000 --- a/.idea/.idea.Moonlight/.idea/indexLayout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/.idea.Moonlight/.idea/projectSettingsUpdater.xml b/.idea/.idea.Moonlight/.idea/projectSettingsUpdater.xml deleted file mode 100644 index 4bb9f4d..0000000 --- a/.idea/.idea.Moonlight/.idea/projectSettingsUpdater.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/.idea.Moonlight/.idea/vcs.xml b/.idea/.idea.Moonlight/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/.idea.Moonlight/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Moonlight.sln b/Moonlight.sln deleted file mode 100644 index 87f7f78..0000000 --- a/Moonlight.sln +++ /dev/null @@ -1,16 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moonlight", "Moonlight\Moonlight.csproj", "{691E5EC2-4B4F-4BD1-9CBC-7D3C6EFC12DA}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {691E5EC2-4B4F-4BD1-9CBC-7D3C6EFC12DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {691E5EC2-4B4F-4BD1-9CBC-7D3C6EFC12DA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {691E5EC2-4B4F-4BD1-9CBC-7D3C6EFC12DA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {691E5EC2-4B4F-4BD1-9CBC-7D3C6EFC12DA}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/Moonlight/BlazorApp.razor b/Moonlight/BlazorApp.razor deleted file mode 100644 index abf100d..0000000 --- a/Moonlight/BlazorApp.razor +++ /dev/null @@ -1,15 +0,0 @@ -@using Moonlight.Core.UI.Layouts - - - - - - - - - Not found - - Sorry, there's nothing at this address. - - - \ No newline at end of file diff --git a/Moonlight/Core/Actions/Dummy/DummyActions.cs b/Moonlight/Core/Actions/Dummy/DummyActions.cs deleted file mode 100644 index 4f11be2..0000000 --- a/Moonlight/Core/Actions/Dummy/DummyActions.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Moonlight.Features.ServiceManagement.Entities; -using Moonlight.Features.ServiceManagement.Models.Abstractions; - -namespace Moonlight.Core.Actions.Dummy; - -public class DummyActions : ServiceActions -{ - public override Task Create(IServiceProvider provider, Service service) - { - return Task.CompletedTask; - } - - public override Task Update(IServiceProvider provider, Service service) - { - return Task.CompletedTask; - } - - public override Task Delete(IServiceProvider provider, Service service) - { - return Task.CompletedTask; - } -} \ No newline at end of file diff --git a/Moonlight/Core/Actions/Dummy/DummyConfig.cs b/Moonlight/Core/Actions/Dummy/DummyConfig.cs deleted file mode 100644 index f9d7bfa..0000000 --- a/Moonlight/Core/Actions/Dummy/DummyConfig.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.ComponentModel; - -namespace Moonlight.Core.Actions.Dummy; - -public class DummyConfig -{ - [Description("Some description")] - public string String { get; set; } = ""; - public bool Boolean { get; set; } - public int Integer { get; set; } -} \ No newline at end of file diff --git a/Moonlight/Core/Actions/Dummy/DummyServiceDefinition.cs b/Moonlight/Core/Actions/Dummy/DummyServiceDefinition.cs deleted file mode 100644 index 91da0bf..0000000 --- a/Moonlight/Core/Actions/Dummy/DummyServiceDefinition.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Moonlight.Core.Actions.Dummy.Layouts; -using Moonlight.Core.Actions.Dummy.Pages; -using Moonlight.Features.ServiceManagement.Models.Abstractions; - -namespace Moonlight.Core.Actions.Dummy; - -public class DummyServiceDefinition : ServiceDefinition -{ - public override ServiceActions Actions => new DummyActions(); - public override Type ConfigType => typeof(DummyConfig); - public override async Task BuildUserView(ServiceViewContext context) - { - context.Layout = typeof(DummyUser); - - await context.AddPage("Demo", "/demo"); - } - - public override Task BuildAdminView(ServiceViewContext context) - { - context.Layout = typeof(DummyAdmin); - - return Task.CompletedTask; - } -} \ No newline at end of file diff --git a/Moonlight/Core/Actions/Dummy/Layouts/DummyAdmin.razor b/Moonlight/Core/Actions/Dummy/Layouts/DummyAdmin.razor deleted file mode 100644 index 0f7abae..0000000 --- a/Moonlight/Core/Actions/Dummy/Layouts/DummyAdmin.razor +++ /dev/null @@ -1,5 +0,0 @@ -DummyAdmin - -@code { - -} \ No newline at end of file diff --git a/Moonlight/Core/Actions/Dummy/Layouts/DummyUser.razor b/Moonlight/Core/Actions/Dummy/Layouts/DummyUser.razor deleted file mode 100644 index fb0c0ca..0000000 --- a/Moonlight/Core/Actions/Dummy/Layouts/DummyUser.razor +++ /dev/null @@ -1,5 +0,0 @@ -DummyUser - -@code { - -} \ No newline at end of file diff --git a/Moonlight/Core/Actions/Dummy/Pages/DummyPage.razor b/Moonlight/Core/Actions/Dummy/Pages/DummyPage.razor deleted file mode 100644 index b465c85..0000000 --- a/Moonlight/Core/Actions/Dummy/Pages/DummyPage.razor +++ /dev/null @@ -1,5 +0,0 @@ -DummyPage - -@code { - -} \ No newline at end of file diff --git a/Moonlight/Core/Configuration/ConfigV1.cs b/Moonlight/Core/Configuration/ConfigV1.cs deleted file mode 100644 index 51a378f..0000000 --- a/Moonlight/Core/Configuration/ConfigV1.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System.ComponentModel; -using MoonCore.Helpers; -using Moonlight.Features.Advertisement.Configuration; -using Moonlight.Features.FileManager.Configuration; -using Moonlight.Features.Servers.Configuration; -using Moonlight.Features.StoreSystem.Configuration; -using Moonlight.Features.Theming.Configuration; -using Newtonsoft.Json; - -namespace Moonlight.Core.Configuration; - -public class ConfigV1 -{ - [JsonProperty("AppUrl")] - [Description("The url with which moonlight is accessible from the internet. It must not end with a /")] - public string AppUrl { get; set; } = "http://your-moonlight-instance-without-slash.owo"; - - [JsonProperty("Security")] public SecurityData Security { get; set; } = new(); - [JsonProperty("Database")] public DatabaseData Database { get; set; } = new(); - [JsonProperty("MailServer")] public MailServerData MailServer { get; set; } = new(); - - [JsonProperty("Store")] public StoreData Store { get; set; } = new(); - - [JsonProperty("Theme")] public ThemeData Theme { get; set; } = new(); - [JsonProperty("Advertisement")] public AdvertisementData Advertisement { get; set; } = new(); - - [JsonProperty("FileManager")] public FileManagerData FileManager { get; set; } = new(); - - [JsonProperty("WebServer")] public WebServerData WebServer { get; set; } = new(); - - [JsonProperty("Servers")] public ServersData Servers { get; set; } = new(); - - public class WebServerData - { - [JsonProperty("HttpUploadLimit")] - [Description("This sets the kestrel upload limit in megabytes. Changing this will need an restart")] - public int HttpUploadLimit { get; set; } = 100 * 1024; - } - - public class SecurityData - { - [JsonProperty("Token")] - [Description("The security token helio will use to encrypt various things like tokens")] - public string Token { get; set; } = Guid.NewGuid().ToString().Replace("-", ""); - - [JsonProperty("EnableEmailVerify")] - [Description("This will users force to verify their email address if they havent already")] - public bool EnableEmailVerify { get; set; } = false; - - [JsonProperty("EnableReverseProxyMode")] - [Description("Enable this option if you are using a reverse proxy to access moonlight. This will configure some parts of moonlight to act correctly like the ip detection")] - public bool EnableReverseProxyMode { get; set; } = false; - } - - public class DatabaseData - { - [JsonProperty("UseSqlite")] - public bool UseSqlite { get; set; } = false; - - [JsonProperty("SqlitePath")] - public string SqlitePath { get; set; } = PathBuilder.File("storage", "data.sqlite"); - - [JsonProperty("Host")] - public string Host { get; set; } = "your.db.host"; - - [JsonProperty("Port")] - public int Port { get; set; } = 3306; - - [JsonProperty("Username")] - public string Username { get; set; } = "moonlight_user"; - - [JsonProperty("Password")] - public string Password { get; set; } = "s3cr3t"; - - [JsonProperty("Database")] - public string Database { get; set; } = "moonlight_db"; - } - - public class MailServerData - { - [JsonProperty("Host")] public string Host { get; set; } = "your.email.host"; - - [JsonProperty("Port")] public int Port { get; set; } = 465; - - [JsonProperty("Email")] public string Email { get; set; } = "noreply@your.email.host"; - - [JsonProperty("Password")] public string Password { get; set; } = "s3cr3t"; - - [JsonProperty("UseSsl")] public bool UseSsl { get; set; } = true; - - [JsonProperty("SenderName")] - [Description("This will be shown as the system emails sender name in apps like gmail")] - public string SenderName { get; set; } = "Moonlight System"; - } -} \ No newline at end of file diff --git a/Moonlight/Core/Database/DataContext.cs b/Moonlight/Core/Database/DataContext.cs deleted file mode 100644 index 53a354a..0000000 --- a/Moonlight/Core/Database/DataContext.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using MoonCore.Services; -using Moonlight.Core.Configuration; -using Moonlight.Core.Database.Entities; -using Moonlight.Core.Services; -using Moonlight.Features.Community.Entities; -using Moonlight.Features.Servers.Entities; -using Moonlight.Features.ServiceManagement.Entities; -using Moonlight.Features.StoreSystem.Entities; -using Moonlight.Features.Theming.Entities; -using Moonlight.Features.Ticketing.Entities; - -namespace Moonlight.Core.Database; - -public class DataContext : DbContext -{ - private readonly ConfigService ConfigService; - - public DbSet Users { get; set; } - - // Store - public DbSet Categories { get; set; } - public DbSet Products { get; set; } - public DbSet Services { get; set; } - public DbSet ServiceShares { get; set; } - - public DbSet GiftCodes { get; set; } - public DbSet GiftCodeUses { get; set; } - - public DbSet Coupons { get; set; } - public DbSet CouponUses { get; set; } - - // Community - public DbSet Posts { get; set; } - public DbSet PostComments { get; set; } - public DbSet PostLikes { get; set; } - public DbSet WordFilters { get; set; } - - // Tickets - public DbSet Tickets { get; set; } - public DbSet TicketMessages { get; set; } - - // Themes - public DbSet Themes { get; set; } - - // Servers - public DbSet Servers { get; set; } - public DbSet ServerAllocations { get; set; } - public DbSet ServerImages { get; set; } - public DbSet ServerNodes { get; set; } - public DbSet ServerVariables { get; set; } - public DbSet ServerDockerImages { get; set; } - public DbSet ServerImageVariables { get; set; } - public DbSet ServerSchedules { get; set; } - - public DataContext(ConfigService configService) - { - ConfigService = configService; - } - - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - if (!optionsBuilder.IsConfigured) - { - var config = ConfigService.Get().Database; - - if (config.UseSqlite) - optionsBuilder.UseSqlite($"Data Source={config.SqlitePath}"); - else - { - var connectionString = $"host={config.Host};" + - $"port={config.Port};" + - $"database={config.Database};" + - $"uid={config.Username};" + - $"pwd={config.Password}"; - - optionsBuilder.UseMySql( - connectionString, - ServerVersion.AutoDetect(connectionString), - builder => builder.EnableRetryOnFailure(5) - ); - } - } - } -} \ No newline at end of file diff --git a/Moonlight/Core/Database/Entities/User.cs b/Moonlight/Core/Database/Entities/User.cs deleted file mode 100644 index 1c83022..0000000 --- a/Moonlight/Core/Database/Entities/User.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Moonlight.Features.StoreSystem.Entities; - -namespace Moonlight.Core.Database.Entities; - -public class User -{ - public int Id { get; set; } - public string Username { get; set; } - public string Email { get; set; } - public string Password { get; set; } - public string? Avatar { get; set; } = null; - public string? TotpKey { get; set; } = null; - - // Store - public double Balance { get; set; } - public List Transactions { get; set; } = new(); - - public List CouponUses { get; set; } = new(); - public List GiftCodeUses { get; set; } = new(); - - // Meta data - public string Flags { get; set; } = ""; - public int Permissions { get; set; } = 0; - - // Timestamps - public DateTime TokenValidTimestamp { get; set; } = DateTime.UtcNow.AddMinutes(-10); - public DateTime CreatedAt { get; set; } = DateTime.UtcNow; -} \ No newline at end of file diff --git a/Moonlight/Core/Database/Migrations/20231013200303_AddedUser.Designer.cs b/Moonlight/Core/Database/Migrations/20231013200303_AddedUser.Designer.cs deleted file mode 100644 index 7eed2ec..0000000 --- a/Moonlight/Core/Database/Migrations/20231013200303_AddedUser.Designer.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Moonlight.Core.Database; -using Moonlight.Core.Database; - -#nullable disable - -namespace Moonlight.Core.Database.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20231013200303_AddedUser")] - partial class AddedUser - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Avatar") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Email") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Flags") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Permissions") - .HasColumnType("INTEGER"); - - b.Property("TokenValidTimestamp") - .HasColumnType("TEXT"); - - b.Property("TotpKey") - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/Core/Database/Migrations/20231013200303_AddedUser.cs b/Moonlight/Core/Database/Migrations/20231013200303_AddedUser.cs deleted file mode 100644 index a187145..0000000 --- a/Moonlight/Core/Database/Migrations/20231013200303_AddedUser.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.Core.Database.Migrations -{ - /// - public partial class AddedUser : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Username = table.Column(type: "TEXT", nullable: false), - Email = table.Column(type: "TEXT", nullable: false), - Password = table.Column(type: "TEXT", nullable: false), - Avatar = table.Column(type: "TEXT", nullable: true), - TotpKey = table.Column(type: "TEXT", nullable: true), - Flags = table.Column(type: "TEXT", nullable: false), - Permissions = table.Column(type: "INTEGER", nullable: false), - TokenValidTimestamp = table.Column(type: "TEXT", nullable: false), - CreatedAt = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Users"); - } - } -} diff --git a/Moonlight/Core/Database/Migrations/20231017075519_AddStoreModels.Designer.cs b/Moonlight/Core/Database/Migrations/20231017075519_AddStoreModels.Designer.cs deleted file mode 100644 index 3c90fdb..0000000 --- a/Moonlight/Core/Database/Migrations/20231017075519_AddStoreModels.Designer.cs +++ /dev/null @@ -1,342 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Moonlight.Core.Database; -using Moonlight.Core.Database; - -#nullable disable - -namespace Moonlight.Core.Database.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20231017075519_AddStoreModels")] - partial class AddStoreModels - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Category", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Coupon", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Amount") - .HasColumnType("INTEGER"); - - b.Property("Code") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Percent") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.ToTable("Coupons"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.CouponUse", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CouponId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("CouponId"); - - b.ToTable("CouponUses"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.GiftCode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Amount") - .HasColumnType("INTEGER"); - - b.Property("Code") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Value") - .HasColumnType("REAL"); - - b.HasKey("Id"); - - b.ToTable("GiftCodes"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.GiftCodeUse", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("GiftCodeId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("GiftCodeId"); - - b.ToTable("GiftCodeUses"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CategoryId") - .HasColumnType("INTEGER"); - - b.Property("ConfigJson") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Description") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Duration") - .HasColumnType("INTEGER"); - - b.Property("MaxPerUser") - .HasColumnType("INTEGER"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Price") - .HasColumnType("REAL"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Stock") - .HasColumnType("INTEGER"); - - b.Property("Type") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Service", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ConfigJsonOverride") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Nickname") - .HasColumnType("TEXT"); - - b.Property("OwnerId") - .HasColumnType("INTEGER"); - - b.Property("ProductId") - .HasColumnType("INTEGER"); - - b.Property("RenewAt") - .HasColumnType("TEXT"); - - b.Property("Suspended") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.HasIndex("ProductId"); - - b.ToTable("Services"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.ServiceShare", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ServiceId") - .HasColumnType("INTEGER"); - - b.Property("UserId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("ServiceId"); - - b.HasIndex("UserId"); - - b.ToTable("ServiceShares"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Avatar") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Email") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Flags") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Permissions") - .HasColumnType("INTEGER"); - - b.Property("TokenValidTimestamp") - .HasColumnType("TEXT"); - - b.Property("TotpKey") - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.CouponUse", b => - { - b.HasOne("Moonlight.Core.Database.Entities.Store.Coupon", "Coupon") - .WithMany() - .HasForeignKey("CouponId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Coupon"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.GiftCodeUse", b => - { - b.HasOne("Moonlight.Core.Database.Entities.Store.GiftCode", "GiftCode") - .WithMany() - .HasForeignKey("GiftCodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("GiftCode"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Product", b => - { - b.HasOne("Moonlight.Core.Database.Entities.Store.Category", "Category") - .WithMany() - .HasForeignKey("CategoryId"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Service", b => - { - b.HasOne("Moonlight.Core.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.Core.Database.Entities.Store.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.ServiceShare", b => - { - b.HasOne("Moonlight.Core.Database.Entities.Store.Service", null) - .WithMany("Shares") - .HasForeignKey("ServiceId"); - - b.HasOne("Moonlight.Core.Database.Entities.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Service", b => - { - b.Navigation("Shares"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/Core/Database/Migrations/20231017075519_AddStoreModels.cs b/Moonlight/Core/Database/Migrations/20231017075519_AddStoreModels.cs deleted file mode 100644 index dcaefe9..0000000 --- a/Moonlight/Core/Database/Migrations/20231017075519_AddStoreModels.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.Core.Database.Migrations -{ - /// - public partial class AddStoreModels : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Categories", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Name = table.Column(type: "TEXT", nullable: false), - Description = table.Column(type: "TEXT", nullable: false), - Slug = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Categories", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Coupons", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Code = table.Column(type: "TEXT", nullable: false), - Percent = table.Column(type: "INTEGER", nullable: false), - Amount = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Coupons", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "GiftCodes", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Code = table.Column(type: "TEXT", nullable: false), - Value = table.Column(type: "REAL", nullable: false), - Amount = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_GiftCodes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Products", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - CategoryId = table.Column(type: "INTEGER", nullable: true), - Name = table.Column(type: "TEXT", nullable: false), - Description = table.Column(type: "TEXT", nullable: false), - Slug = table.Column(type: "TEXT", nullable: false), - Price = table.Column(type: "REAL", nullable: false), - Stock = table.Column(type: "INTEGER", nullable: false), - MaxPerUser = table.Column(type: "INTEGER", nullable: false), - Duration = table.Column(type: "INTEGER", nullable: false), - Type = table.Column(type: "INTEGER", nullable: false), - ConfigJson = table.Column(type: "TEXT", nullable: false), - CreatedAt = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Products", x => x.Id); - table.ForeignKey( - name: "FK_Products_Categories_CategoryId", - column: x => x.CategoryId, - principalTable: "Categories", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "CouponUses", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - CouponId = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_CouponUses", x => x.Id); - table.ForeignKey( - name: "FK_CouponUses_Coupons_CouponId", - column: x => x.CouponId, - principalTable: "Coupons", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "GiftCodeUses", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - GiftCodeId = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_GiftCodeUses", x => x.Id); - table.ForeignKey( - name: "FK_GiftCodeUses_GiftCodes_GiftCodeId", - column: x => x.GiftCodeId, - principalTable: "GiftCodes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Services", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Nickname = table.Column(type: "TEXT", nullable: true), - Suspended = table.Column(type: "INTEGER", nullable: false), - ProductId = table.Column(type: "INTEGER", nullable: false), - ConfigJsonOverride = table.Column(type: "TEXT", nullable: true), - OwnerId = table.Column(type: "INTEGER", nullable: false), - CreatedAt = table.Column(type: "TEXT", nullable: false), - RenewAt = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Services", x => x.Id); - table.ForeignKey( - name: "FK_Services_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Services_Users_OwnerId", - column: x => x.OwnerId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ServiceShares", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - UserId = table.Column(type: "INTEGER", nullable: false), - ServiceId = table.Column(type: "INTEGER", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ServiceShares", x => x.Id); - table.ForeignKey( - name: "FK_ServiceShares_Services_ServiceId", - column: x => x.ServiceId, - principalTable: "Services", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_ServiceShares_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_CouponUses_CouponId", - table: "CouponUses", - column: "CouponId"); - - migrationBuilder.CreateIndex( - name: "IX_GiftCodeUses_GiftCodeId", - table: "GiftCodeUses", - column: "GiftCodeId"); - - migrationBuilder.CreateIndex( - name: "IX_Products_CategoryId", - table: "Products", - column: "CategoryId"); - - migrationBuilder.CreateIndex( - name: "IX_Services_OwnerId", - table: "Services", - column: "OwnerId"); - - migrationBuilder.CreateIndex( - name: "IX_Services_ProductId", - table: "Services", - column: "ProductId"); - - migrationBuilder.CreateIndex( - name: "IX_ServiceShares_ServiceId", - table: "ServiceShares", - column: "ServiceId"); - - migrationBuilder.CreateIndex( - name: "IX_ServiceShares_UserId", - table: "ServiceShares", - column: "UserId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "CouponUses"); - - migrationBuilder.DropTable( - name: "GiftCodeUses"); - - migrationBuilder.DropTable( - name: "ServiceShares"); - - migrationBuilder.DropTable( - name: "Coupons"); - - migrationBuilder.DropTable( - name: "GiftCodes"); - - migrationBuilder.DropTable( - name: "Services"); - - migrationBuilder.DropTable( - name: "Products"); - - migrationBuilder.DropTable( - name: "Categories"); - } - } -} diff --git a/Moonlight/Core/Database/Migrations/20231018203522_AddedUserStoreData.Designer.cs b/Moonlight/Core/Database/Migrations/20231018203522_AddedUserStoreData.Designer.cs deleted file mode 100644 index 4249659..0000000 --- a/Moonlight/Core/Database/Migrations/20231018203522_AddedUserStoreData.Designer.cs +++ /dev/null @@ -1,372 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Moonlight.Core.Database; -using Moonlight.Core.Database; - -#nullable disable - -namespace Moonlight.Core.Database.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20231018203522_AddedUserStoreData")] - partial class AddedUserStoreData - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Category", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Coupon", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Amount") - .HasColumnType("INTEGER"); - - b.Property("Code") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Percent") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.ToTable("Coupons"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.CouponUse", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CouponId") - .HasColumnType("INTEGER"); - - b.Property("UserId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("CouponId"); - - b.HasIndex("UserId"); - - b.ToTable("CouponUses"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.GiftCode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Amount") - .HasColumnType("INTEGER"); - - b.Property("Code") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Value") - .HasColumnType("REAL"); - - b.HasKey("Id"); - - b.ToTable("GiftCodes"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.GiftCodeUse", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("GiftCodeId") - .HasColumnType("INTEGER"); - - b.Property("UserId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("GiftCodeId"); - - b.HasIndex("UserId"); - - b.ToTable("GiftCodeUses"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CategoryId") - .HasColumnType("INTEGER"); - - b.Property("ConfigJson") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Description") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Duration") - .HasColumnType("INTEGER"); - - b.Property("MaxPerUser") - .HasColumnType("INTEGER"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Price") - .HasColumnType("REAL"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Stock") - .HasColumnType("INTEGER"); - - b.Property("Type") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Service", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ConfigJsonOverride") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Nickname") - .HasColumnType("TEXT"); - - b.Property("OwnerId") - .HasColumnType("INTEGER"); - - b.Property("ProductId") - .HasColumnType("INTEGER"); - - b.Property("RenewAt") - .HasColumnType("TEXT"); - - b.Property("Suspended") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.HasIndex("ProductId"); - - b.ToTable("Services"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.ServiceShare", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ServiceId") - .HasColumnType("INTEGER"); - - b.Property("UserId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("ServiceId"); - - b.HasIndex("UserId"); - - b.ToTable("ServiceShares"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Avatar") - .HasColumnType("TEXT"); - - b.Property("Balance") - .HasColumnType("REAL"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Email") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Flags") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Permissions") - .HasColumnType("INTEGER"); - - b.Property("TokenValidTimestamp") - .HasColumnType("TEXT"); - - b.Property("TotpKey") - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.CouponUse", b => - { - b.HasOne("Moonlight.Core.Database.Entities.Store.Coupon", "Coupon") - .WithMany() - .HasForeignKey("CouponId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.Core.Database.Entities.User", null) - .WithMany("CouponUses") - .HasForeignKey("UserId"); - - b.Navigation("Coupon"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.GiftCodeUse", b => - { - b.HasOne("Moonlight.Core.Database.Entities.Store.GiftCode", "GiftCode") - .WithMany() - .HasForeignKey("GiftCodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.Core.Database.Entities.User", null) - .WithMany("GiftCodeUses") - .HasForeignKey("UserId"); - - b.Navigation("GiftCode"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Product", b => - { - b.HasOne("Moonlight.Core.Database.Entities.Store.Category", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Service", b => - { - b.HasOne("Moonlight.Core.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.Core.Database.Entities.Store.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.ServiceShare", b => - { - b.HasOne("Moonlight.Core.Database.Entities.Store.Service", null) - .WithMany("Shares") - .HasForeignKey("ServiceId"); - - b.HasOne("Moonlight.Core.Database.Entities.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Service", b => - { - b.Navigation("Shares"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.User", b => - { - b.Navigation("CouponUses"); - - b.Navigation("GiftCodeUses"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/Core/Database/Migrations/20231018203522_AddedUserStoreData.cs b/Moonlight/Core/Database/Migrations/20231018203522_AddedUserStoreData.cs deleted file mode 100644 index a22bb9e..0000000 --- a/Moonlight/Core/Database/Migrations/20231018203522_AddedUserStoreData.cs +++ /dev/null @@ -1,130 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.Core.Database.Migrations -{ - /// - public partial class AddedUserStoreData : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Products_Categories_CategoryId", - table: "Products"); - - migrationBuilder.AddColumn( - name: "Balance", - table: "Users", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AlterColumn( - name: "CategoryId", - table: "Products", - type: "INTEGER", - nullable: false, - defaultValue: 0, - oldClrType: typeof(int), - oldType: "INTEGER", - oldNullable: true); - - migrationBuilder.AddColumn( - name: "UserId", - table: "GiftCodeUses", - type: "INTEGER", - nullable: true); - - migrationBuilder.AddColumn( - name: "UserId", - table: "CouponUses", - type: "INTEGER", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_GiftCodeUses_UserId", - table: "GiftCodeUses", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_CouponUses_UserId", - table: "CouponUses", - column: "UserId"); - - migrationBuilder.AddForeignKey( - name: "FK_CouponUses_Users_UserId", - table: "CouponUses", - column: "UserId", - principalTable: "Users", - principalColumn: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_GiftCodeUses_Users_UserId", - table: "GiftCodeUses", - column: "UserId", - principalTable: "Users", - principalColumn: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_Products_Categories_CategoryId", - table: "Products", - column: "CategoryId", - principalTable: "Categories", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_CouponUses_Users_UserId", - table: "CouponUses"); - - migrationBuilder.DropForeignKey( - name: "FK_GiftCodeUses_Users_UserId", - table: "GiftCodeUses"); - - migrationBuilder.DropForeignKey( - name: "FK_Products_Categories_CategoryId", - table: "Products"); - - migrationBuilder.DropIndex( - name: "IX_GiftCodeUses_UserId", - table: "GiftCodeUses"); - - migrationBuilder.DropIndex( - name: "IX_CouponUses_UserId", - table: "CouponUses"); - - migrationBuilder.DropColumn( - name: "Balance", - table: "Users"); - - migrationBuilder.DropColumn( - name: "UserId", - table: "GiftCodeUses"); - - migrationBuilder.DropColumn( - name: "UserId", - table: "CouponUses"); - - migrationBuilder.AlterColumn( - name: "CategoryId", - table: "Products", - type: "INTEGER", - nullable: true, - oldClrType: typeof(int), - oldType: "INTEGER"); - - migrationBuilder.AddForeignKey( - name: "FK_Products_Categories_CategoryId", - table: "Products", - column: "CategoryId", - principalTable: "Categories", - principalColumn: "Id"); - } - } -} diff --git a/Moonlight/Core/Database/Migrations/20231018204737_AddedTransactions.Designer.cs b/Moonlight/Core/Database/Migrations/20231018204737_AddedTransactions.Designer.cs deleted file mode 100644 index caabb9e..0000000 --- a/Moonlight/Core/Database/Migrations/20231018204737_AddedTransactions.Designer.cs +++ /dev/null @@ -1,404 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Moonlight.Core.Database; -using Moonlight.Core.Database; - -#nullable disable - -namespace Moonlight.Core.Database.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20231018204737_AddedTransactions")] - partial class AddedTransactions - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Category", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Coupon", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Amount") - .HasColumnType("INTEGER"); - - b.Property("Code") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Percent") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.ToTable("Coupons"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.CouponUse", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CouponId") - .HasColumnType("INTEGER"); - - b.Property("UserId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("CouponId"); - - b.HasIndex("UserId"); - - b.ToTable("CouponUses"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.GiftCode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Amount") - .HasColumnType("INTEGER"); - - b.Property("Code") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Value") - .HasColumnType("REAL"); - - b.HasKey("Id"); - - b.ToTable("GiftCodes"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.GiftCodeUse", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("GiftCodeId") - .HasColumnType("INTEGER"); - - b.Property("UserId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("GiftCodeId"); - - b.HasIndex("UserId"); - - b.ToTable("GiftCodeUses"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CategoryId") - .HasColumnType("INTEGER"); - - b.Property("ConfigJson") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Description") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Duration") - .HasColumnType("INTEGER"); - - b.Property("MaxPerUser") - .HasColumnType("INTEGER"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Price") - .HasColumnType("REAL"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Stock") - .HasColumnType("INTEGER"); - - b.Property("Type") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Service", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ConfigJsonOverride") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Nickname") - .HasColumnType("TEXT"); - - b.Property("OwnerId") - .HasColumnType("INTEGER"); - - b.Property("ProductId") - .HasColumnType("INTEGER"); - - b.Property("RenewAt") - .HasColumnType("TEXT"); - - b.Property("Suspended") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.HasIndex("ProductId"); - - b.ToTable("Services"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.ServiceShare", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ServiceId") - .HasColumnType("INTEGER"); - - b.Property("UserId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("ServiceId"); - - b.HasIndex("UserId"); - - b.ToTable("ServiceShares"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Transaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Price") - .HasColumnType("REAL"); - - b.Property("Text") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("UserId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Transaction"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Avatar") - .HasColumnType("TEXT"); - - b.Property("Balance") - .HasColumnType("REAL"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Email") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Flags") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Permissions") - .HasColumnType("INTEGER"); - - b.Property("TokenValidTimestamp") - .HasColumnType("TEXT"); - - b.Property("TotpKey") - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.CouponUse", b => - { - b.HasOne("Moonlight.Core.Database.Entities.Store.Coupon", "Coupon") - .WithMany() - .HasForeignKey("CouponId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.Core.Database.Entities.User", null) - .WithMany("CouponUses") - .HasForeignKey("UserId"); - - b.Navigation("Coupon"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.GiftCodeUse", b => - { - b.HasOne("Moonlight.Core.Database.Entities.Store.GiftCode", "GiftCode") - .WithMany() - .HasForeignKey("GiftCodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.Core.Database.Entities.User", null) - .WithMany("GiftCodeUses") - .HasForeignKey("UserId"); - - b.Navigation("GiftCode"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Product", b => - { - b.HasOne("Moonlight.Core.Database.Entities.Store.Category", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Service", b => - { - b.HasOne("Moonlight.Core.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.Core.Database.Entities.Store.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.ServiceShare", b => - { - b.HasOne("Moonlight.Core.Database.Entities.Store.Service", null) - .WithMany("Shares") - .HasForeignKey("ServiceId"); - - b.HasOne("Moonlight.Core.Database.Entities.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Transaction", b => - { - b.HasOne("Moonlight.Core.Database.Entities.User", null) - .WithMany("Transactions") - .HasForeignKey("UserId"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.Store.Service", b => - { - b.Navigation("Shares"); - }); - - modelBuilder.Entity("Moonlight.Core.Database.Entities.User", b => - { - b.Navigation("CouponUses"); - - b.Navigation("GiftCodeUses"); - - b.Navigation("Transactions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/Core/Database/Migrations/20231018204737_AddedTransactions.cs b/Moonlight/Core/Database/Migrations/20231018204737_AddedTransactions.cs deleted file mode 100644 index 72a6a61..0000000 --- a/Moonlight/Core/Database/Migrations/20231018204737_AddedTransactions.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.Core.Database.Migrations -{ - /// - public partial class AddedTransactions : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Transaction", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Price = table.Column(type: "REAL", nullable: false), - Text = table.Column(type: "TEXT", nullable: false), - UserId = table.Column
Sorry, there's nothing at this address.