Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgresql adapter #10

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
Add postgresql initial migration
  • Loading branch information
mrahhal committed Nov 25, 2017
commit 6aea52a8cdb2a3caa7f43bcbe3153e7cbad1ac8c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;

namespace MR.AspNetCore.Jobs.Migrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Jobs");

migrationBuilder.CreateTable(
name: "CronJobs",
schema: "Jobs",
columns: table => new
{
Id = table.Column<string>(nullable: false),
Cron = table.Column<string>(nullable: true),
LastRun = table.Column<DateTime>(nullable: false),
Name = table.Column<string>(nullable: false),
TypeName = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CronJobs", x => x.Id);
});

migrationBuilder.CreateTable(
name: "Jobs",
schema: "Jobs",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
Added = table.Column<DateTime>(nullable: false),
Data = table.Column<string>(nullable: true),
Due = table.Column<DateTime>(nullable: true),
ExpiresAt = table.Column<DateTime>(nullable: true),
Retries = table.Column<int>(nullable: false),
StateName = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Jobs", x => x.Id);
});

migrationBuilder.CreateTable(
name: "JobQueue",
schema: "Jobs",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
JobId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_JobQueue", x => x.Id);
table.ForeignKey(
name: "FK_JobQueue_Jobs_JobId",
column: x => x.JobId,
principalSchema: "Jobs",
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});

migrationBuilder.CreateIndex(
name: "IX_CronJobs_Name",
schema: "Jobs",
table: "CronJobs",
column: "Name",
unique: true);

migrationBuilder.CreateIndex(
name: "IX_JobQueue_JobId",
schema: "Jobs",
table: "JobQueue",
column: "JobId");

migrationBuilder.CreateIndex(
name: "IX_Jobs_StateName",
schema: "Jobs",
table: "Jobs",
column: "StateName");

migrationBuilder.CreateIndex(
name: "IX_Jobs_Due_StateName",
schema: "Jobs",
table: "Jobs",
columns: new[] { "Due", "StateName" });
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CronJobs",
schema: "Jobs");

migrationBuilder.DropTable(
name: "JobQueue",
schema: "Jobs");

migrationBuilder.DropTable(
name: "Jobs",
schema: "Jobs");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal;
using MR.AspNetCore.Jobs.Models;
using System;

namespace MR.AspNetCore.Jobs.Migrations
{
[DbContext(typeof(JobsDbContext))]
partial class JobsDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Jobs")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.0.1-rtm-125");

modelBuilder.Entity("MR.AspNetCore.Jobs.Models.CronJob", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();

b.Property<string>("Cron");

b.Property<DateTime>("LastRun");

b.Property<string>("Name")
.IsRequired();

b.Property<string>("TypeName");

b.HasKey("Id");

b.HasIndex("Name")
.IsUnique();

b.ToTable("CronJobs");
});

modelBuilder.Entity("MR.AspNetCore.Jobs.Models.Job", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();

b.Property<DateTime>("Added");

b.Property<string>("Data");

b.Property<DateTime?>("Due");

b.Property<DateTime?>("ExpiresAt");

b.Property<int>("Retries");

b.Property<string>("StateName")
.IsRequired();

b.HasKey("Id");

b.HasIndex("StateName");

b.HasIndex("Due", "StateName");

b.ToTable("Jobs");
});

modelBuilder.Entity("MR.AspNetCore.Jobs.Models.JobQueue", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();

b.Property<int>("JobId");

b.HasKey("Id");

b.HasIndex("JobId");

b.ToTable("JobQueue");
});

modelBuilder.Entity("MR.AspNetCore.Jobs.Models.JobQueue", b =>
{
b.HasOne("MR.AspNetCore.Jobs.Models.Job", "Job")
.WithMany()
.HasForeignKey("JobId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}