diff --git a/db/05-user-table.sql b/db/05-user-table.sql deleted file mode 100644 index 0e83e11..0000000 --- a/db/05-user-table.sql +++ /dev/null @@ -1,26 +0,0 @@ --- Add user table - -\connect ews - -DROP TABLE IF EXISTS bohrung."user"; - -CREATE TABLE bohrung.user ( - user_id integer NOT NULL, - user_name text NOT NULL, - user_role integer NOT NULL, - new_date timestamp without time zone DEFAULT now() NOT NULL, - mut_date timestamp without time zone, - new_usr character varying DEFAULT "current_user"() NOT NULL, - mut_usr character varying -); - -CREATE SEQUENCE bohrung.user_user_id_seq - START WITH 100 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -ALTER SEQUENCE bohrung.user_user_id_seq OWNED BY bohrung.user.user_id; -ALTER TABLE ONLY bohrung.user ALTER COLUMN user_id SET DEFAULT nextval('bohrung.user_user_id_seq'::regclass); -ALTER TABLE ONLY bohrung.user ADD CONSTRAINT pkey_user_user_id PRIMARY KEY (user_id); diff --git a/src/Migrations/20220714182758_AddUserTable.Designer.cs b/src/Migrations/20220714182758_AddUserTable.Designer.cs new file mode 100644 index 0000000..72c28b8 --- /dev/null +++ b/src/Migrations/20220714182758_AddUserTable.Designer.cs @@ -0,0 +1,743 @@ +// +using System; +using EWS; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using NetTopologySuite.Geometries; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace EWS.Migrations +{ + [DbContext(typeof(EwsContext))] + [Migration("20220714182758_AddUserTable")] + partial class AddUserTable + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("bohrung") + .HasAnnotation("ProductVersion", "6.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "postgis"); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("EWS.Models.Bohrprofil", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("bohrprofil_id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Bemerkung") + .HasColumnType("text") + .HasColumnName("bemerkung"); + + b.Property("BohrungId") + .HasColumnType("integer") + .HasColumnName("bohrung_id"); + + b.Property("Datum") + .HasColumnType("timestamp with time zone") + .HasColumnName("datum"); + + b.Property("Endteufe") + .HasColumnType("integer") + .HasColumnName("endteufe"); + + b.Property("Erstellungsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("new_date"); + + b.Property("FormationEndtiefe") + .HasColumnType("integer") + .HasColumnName("fmeto"); + + b.Property("FormationFels") + .HasColumnType("integer") + .HasColumnName("fmfelso"); + + b.Property("HFormationEndtiefeId") + .HasColumnType("integer") + .HasColumnName("h_fmeto"); + + b.Property("HFormationFelsId") + .HasColumnType("integer") + .HasColumnName("h_fmfelso"); + + b.Property("HQualitaetId") + .HasColumnType("integer") + .HasColumnName("h_quali"); + + b.Property("HTektonikId") + .HasColumnType("integer") + .HasColumnName("h_tektonik"); + + b.Property("Kote") + .HasColumnType("integer") + .HasColumnName("kote"); + + b.Property("Mutationsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("mut_date"); + + b.Property("QualitaetBemerkung") + .HasColumnType("text") + .HasColumnName("qualibem"); + + b.Property("QualitaetId") + .HasColumnType("integer") + .HasColumnName("quali"); + + b.Property("Tektonik") + .HasColumnType("integer") + .HasColumnName("tektonik"); + + b.Property("UserErstellung") + .IsRequired() + .HasColumnType("text") + .HasColumnName("new_usr"); + + b.Property("UserMutation") + .HasColumnType("text") + .HasColumnName("mut_usr"); + + b.HasKey("Id"); + + b.HasIndex("BohrungId"); + + b.HasIndex("HFormationEndtiefeId"); + + b.HasIndex("HFormationFelsId"); + + b.HasIndex("HQualitaetId"); + + b.HasIndex("HTektonikId"); + + b.HasIndex("QualitaetId"); + + b.ToTable("bohrprofil", "bohrung"); + }); + + modelBuilder.Entity("EWS.Models.Bohrung", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("bohrung_id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AblenkungId") + .HasColumnType("integer") + .HasColumnName("ablenkung"); + + b.Property("Bemerkung") + .HasColumnType("text") + .HasColumnName("bemerkung"); + + b.Property("Bezeichnung") + .IsRequired() + .HasColumnType("text") + .HasColumnName("bezeichnung"); + + b.Property("Datum") + .HasColumnType("timestamp with time zone") + .HasColumnName("datum"); + + b.Property("DurchmesserBohrloch") + .HasColumnType("integer") + .HasColumnName("durchmesserbohrloch"); + + b.Property("Erstellungsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("new_date"); + + b.Property("Geometrie") + .HasColumnType("geometry") + .HasColumnName("wkb_geometry"); + + b.Property("HAblenkung") + .HasColumnType("integer") + .HasColumnName("h_ablenkung"); + + b.Property("HQualitaetId") + .HasColumnType("integer") + .HasColumnName("h_quali"); + + b.Property("Mutationsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("mut_date"); + + b.Property("Qualitaet") + .HasColumnType("integer") + .HasColumnName("quali"); + + b.Property("QualitaetBemerkung") + .HasColumnType("text") + .HasColumnName("qualibem"); + + b.Property("QuelleRef") + .HasColumnType("text") + .HasColumnName("quelleref"); + + b.Property("StandortId") + .HasColumnType("integer") + .HasColumnName("standort_id"); + + b.Property("UserErstellung") + .IsRequired() + .HasColumnType("text") + .HasColumnName("new_usr"); + + b.Property("UserMutation") + .HasColumnType("text") + .HasColumnName("mut_usr"); + + b.HasKey("Id"); + + b.HasIndex("AblenkungId"); + + b.HasIndex("HQualitaetId"); + + b.HasIndex("StandortId"); + + b.ToTable("bohrung", "bohrung"); + }); + + modelBuilder.Entity("EWS.Models.Code", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("code_id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CodetypId") + .HasColumnType("integer") + .HasColumnName("codetyp_id"); + + b.Property("Erstellungsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("new_date"); + + b.Property("Kurztext") + .IsRequired() + .HasColumnType("text") + .HasColumnName("kurztext"); + + b.Property("Mutationsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("mut_date"); + + b.Property("Sortierung") + .HasColumnType("integer") + .HasColumnName("sort"); + + b.Property("Text") + .HasColumnType("text") + .HasColumnName("text"); + + b.Property("UserErstellung") + .IsRequired() + .HasColumnType("text") + .HasColumnName("new_usr"); + + b.Property("UserMutation") + .HasColumnType("text") + .HasColumnName("mut_usr"); + + b.HasKey("Id"); + + b.HasIndex("CodetypId"); + + b.ToTable("code", "bohrung"); + }); + + modelBuilder.Entity("EWS.Models.CodeSchicht", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("codeschicht_id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Erstellungsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("new_date"); + + b.Property("Kurztext") + .IsRequired() + .HasColumnType("text") + .HasColumnName("kurztext"); + + b.Property("Mutationsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("mut_date"); + + b.Property("Sortierung") + .HasColumnType("integer") + .HasColumnName("sort"); + + b.Property("Text") + .IsRequired() + .HasColumnType("text") + .HasColumnName("text"); + + b.Property("UserErstellung") + .IsRequired() + .HasColumnType("text") + .HasColumnName("new_usr"); + + b.Property("UserMutation") + .HasColumnType("text") + .HasColumnName("mut_usr"); + + b.HasKey("Id"); + + b.ToTable("codeschicht", "bohrung"); + }); + + modelBuilder.Entity("EWS.Models.CodeTyp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("codetyp_id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Erstellungsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("new_date"); + + b.Property("Kurztext") + .IsRequired() + .HasColumnType("text") + .HasColumnName("kurztext"); + + b.Property("Mutationsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("mut_date"); + + b.Property("Text") + .IsRequired() + .HasColumnType("text") + .HasColumnName("text"); + + b.Property("UserErstellung") + .IsRequired() + .HasColumnType("text") + .HasColumnName("new_usr"); + + b.Property("UserMutation") + .HasColumnType("text") + .HasColumnName("mut_usr"); + + b.HasKey("Id"); + + b.ToTable("codetyp", "bohrung"); + }); + + modelBuilder.Entity("EWS.Models.Schicht", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("schicht_id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Bemerkung") + .HasColumnType("text") + .HasColumnName("bemerkung"); + + b.Property("BohrprofilId") + .HasColumnType("integer") + .HasColumnName("bohrprofil_id"); + + b.Property("CodeSchichtId") + .HasColumnType("integer") + .HasColumnName("schichten_id"); + + b.Property("Erstellungsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("new_date"); + + b.Property("HQualitaetId") + .HasColumnType("integer") + .HasColumnName("h_quali"); + + b.Property("Mutationsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("mut_date"); + + b.Property("QualitaetBemerkung") + .HasColumnType("text") + .HasColumnName("qualibem"); + + b.Property("QualitaetId") + .HasColumnType("integer") + .HasColumnName("quali"); + + b.Property("Tiefe") + .HasColumnType("real") + .HasColumnName("tiefe"); + + b.Property("UserErstellung") + .IsRequired() + .HasColumnType("text") + .HasColumnName("new_usr"); + + b.Property("UserMutation") + .HasColumnType("text") + .HasColumnName("mut_usr"); + + b.HasKey("Id"); + + b.HasIndex("BohrprofilId"); + + b.HasIndex("CodeSchichtId"); + + b.HasIndex("HQualitaetId"); + + b.HasIndex("QualitaetId"); + + b.ToTable("schicht", "bohrung"); + }); + + modelBuilder.Entity("EWS.Models.Standort", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("standort_id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AfuDatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("afu_date"); + + b.Property("AfuUser") + .HasColumnType("text") + .HasColumnName("afu_usr"); + + b.Property("Bemerkung") + .HasColumnType("text") + .HasColumnName("bemerkung"); + + b.Property("Bezeichnung") + .IsRequired() + .HasColumnType("text") + .HasColumnName("bezeichnung"); + + b.Property("Erstellungsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("new_date"); + + b.Property("FreigabeAfu") + .HasColumnType("boolean") + .HasColumnName("freigabe_afu"); + + b.Property("Gemeinde") + .HasColumnType("text") + .HasColumnName("gemeinde"); + + b.Property("GrundbuchNr") + .HasColumnType("text") + .HasColumnName("gbnummer"); + + b.Property("Mutationsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("mut_date"); + + b.Property("UserErstellung") + .IsRequired() + .HasColumnType("text") + .HasColumnName("new_usr"); + + b.Property("UserMutation") + .HasColumnType("text") + .HasColumnName("mut_usr"); + + b.HasKey("Id"); + + b.ToTable("standort", "bohrung"); + }); + + modelBuilder.Entity("EWS.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("user_id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Erstellungsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("new_date"); + + b.Property("Mutationsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("mut_date"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("user_name"); + + b.Property("Role") + .HasColumnType("integer") + .HasColumnName("user_role"); + + b.Property("UserErstellung") + .IsRequired() + .HasColumnType("text") + .HasColumnName("new_usr"); + + b.Property("UserMutation") + .HasColumnType("text") + .HasColumnName("mut_usr"); + + b.HasKey("Id"); + + b.ToTable("user", "bohrung"); + }); + + modelBuilder.Entity("EWS.Models.Vorkommnis", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("vorkommnis_id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Bemerkung") + .HasColumnType("text") + .HasColumnName("bemerkung"); + + b.Property("BohrprofilId") + .HasColumnType("integer") + .HasColumnName("bohrprofil_id"); + + b.Property("Erstellungsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("new_date"); + + b.Property("HQualitaetId") + .HasColumnType("integer") + .HasColumnName("h_quali"); + + b.Property("HTypId") + .HasColumnType("integer") + .HasColumnName("h_typ"); + + b.Property("Mutationsdatum") + .HasColumnType("timestamp with time zone") + .HasColumnName("mut_date"); + + b.Property("Qualitaet") + .HasColumnType("integer") + .HasColumnName("quali"); + + b.Property("QualitaetBemerkung") + .HasColumnType("text") + .HasColumnName("qualibem"); + + b.Property("Tiefe") + .HasColumnType("real") + .HasColumnName("tiefe"); + + b.Property("Typ") + .HasColumnType("integer") + .HasColumnName("typ"); + + b.Property("UserErstellung") + .IsRequired() + .HasColumnType("text") + .HasColumnName("new_usr"); + + b.Property("UserMutation") + .HasColumnType("text") + .HasColumnName("mut_usr"); + + b.HasKey("Id"); + + b.HasIndex("BohrprofilId"); + + b.HasIndex("HQualitaetId"); + + b.HasIndex("HTypId"); + + b.ToTable("vorkommnis", "bohrung"); + }); + + modelBuilder.Entity("EWS.Models.Bohrprofil", b => + { + b.HasOne("EWS.Models.Bohrung", null) + .WithMany("Bohrprofile") + .HasForeignKey("BohrungId"); + + b.HasOne("EWS.Models.CodeTyp", "HFormationEndtiefe") + .WithMany() + .HasForeignKey("HFormationEndtiefeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EWS.Models.CodeTyp", "HFormationFels") + .WithMany() + .HasForeignKey("HFormationFelsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EWS.Models.Code", "HQualitaet") + .WithMany() + .HasForeignKey("HQualitaetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EWS.Models.CodeTyp", "HTektonik") + .WithMany() + .HasForeignKey("HTektonikId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EWS.Models.Code", "Qualitaet") + .WithMany() + .HasForeignKey("QualitaetId"); + + b.Navigation("HFormationEndtiefe"); + + b.Navigation("HFormationFels"); + + b.Navigation("HQualitaet"); + + b.Navigation("HTektonik"); + + b.Navigation("Qualitaet"); + }); + + modelBuilder.Entity("EWS.Models.Bohrung", b => + { + b.HasOne("EWS.Models.CodeTyp", "Ablenkung") + .WithMany() + .HasForeignKey("AblenkungId"); + + b.HasOne("EWS.Models.CodeTyp", "HQualitaet") + .WithMany() + .HasForeignKey("HQualitaetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EWS.Models.Standort", null) + .WithMany("Bohrungen") + .HasForeignKey("StandortId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ablenkung"); + + b.Navigation("HQualitaet"); + }); + + modelBuilder.Entity("EWS.Models.Code", b => + { + b.HasOne("EWS.Models.CodeTyp", "Codetyp") + .WithMany() + .HasForeignKey("CodetypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Codetyp"); + }); + + modelBuilder.Entity("EWS.Models.Schicht", b => + { + b.HasOne("EWS.Models.Bohrprofil", null) + .WithMany("Schichten") + .HasForeignKey("BohrprofilId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EWS.Models.CodeSchicht", "CodeSchicht") + .WithMany() + .HasForeignKey("CodeSchichtId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EWS.Models.CodeTyp", "HQualitaet") + .WithMany() + .HasForeignKey("HQualitaetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EWS.Models.Code", "Qualitaet") + .WithMany() + .HasForeignKey("QualitaetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CodeSchicht"); + + b.Navigation("HQualitaet"); + + b.Navigation("Qualitaet"); + }); + + modelBuilder.Entity("EWS.Models.Vorkommnis", b => + { + b.HasOne("EWS.Models.Bohrprofil", null) + .WithMany("Vorkomnisse") + .HasForeignKey("BohrprofilId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EWS.Models.Code", "HQualitaet") + .WithMany() + .HasForeignKey("HQualitaetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EWS.Models.CodeTyp", "HTyp") + .WithMany() + .HasForeignKey("HTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("HQualitaet"); + + b.Navigation("HTyp"); + }); + + modelBuilder.Entity("EWS.Models.Bohrprofil", b => + { + b.Navigation("Schichten"); + + b.Navigation("Vorkomnisse"); + }); + + modelBuilder.Entity("EWS.Models.Bohrung", b => + { + b.Navigation("Bohrprofile"); + }); + + modelBuilder.Entity("EWS.Models.Standort", b => + { + b.Navigation("Bohrungen"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrations/20220714182758_AddUserTable.cs b/src/Migrations/20220714182758_AddUserTable.cs new file mode 100644 index 0000000..136e125 --- /dev/null +++ b/src/Migrations/20220714182758_AddUserTable.cs @@ -0,0 +1,33 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EWS.Migrations +{ + public partial class AddUserTable : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "user", + schema: "bohrung", + columns: table => new + { + user_id = table.Column(type: "SERIAL", nullable: false), + user_name = table.Column(maxLength: 50, nullable: false), + user_role = table.Column(nullable: false), + new_date = table.Column(type: "timestamp without time zone", defaultValueSql: "now()", nullable: false), + mut_date = table.Column(type: "timestamp without time zone", nullable: true), + new_usr = table.Column(type: "character varying", defaultValueSql: "current_user", nullable: false), + mut_usr = table.Column(type: "character varying", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("pkey_user_user_id", x => x.user_id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) => + migrationBuilder.DropTable(name: "user"); + } +} diff --git a/src/Migrations/EwsContextModelSnapshot.cs b/src/Migrations/EwsContextModelSnapshot.cs index 4afab50..5b1420b 100644 --- a/src/Migrations/EwsContextModelSnapshot.cs +++ b/src/Migrations/EwsContextModelSnapshot.cs @@ -447,8 +447,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("boolean") .HasColumnName("freigabe_afu"); - b.Property("Gemeinde") - .HasColumnType("integer") + b.Property("Gemeinde") + .HasColumnType("text") .HasColumnName("gemeinde"); b.Property("GrundbuchNr")