using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace IOL.GreatOffice.Api.Migrations { public partial class InitialProjectAndCustomer : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "customer_groups", columns: table => new { id = table.Column(type: "uuid", nullable: false), name = table.Column(type: "text", nullable: true), created_at = table.Column(type: "timestamp with time zone", nullable: false), modified_at = table.Column(type: "timestamp with time zone", nullable: true), deleted = table.Column(type: "boolean", nullable: false), user_id = table.Column(type: "uuid", nullable: true), tenant_id = table.Column(type: "uuid", nullable: true), modified_by_id = table.Column(type: "uuid", nullable: true), created_by_id = table.Column(type: "uuid", nullable: true), deleted_by_id = table.Column(type: "uuid", nullable: true) }, constraints: table => { table.PrimaryKey("pk_customer_groups", x => x.id); }); migrationBuilder.CreateTable( name: "projects", columns: table => new { id = table.Column(type: "uuid", nullable: false), name = table.Column(type: "text", nullable: true), description = table.Column(type: "text", nullable: true), start = table.Column(type: "timestamp with time zone", nullable: true), stop = table.Column(type: "timestamp with time zone", nullable: true), created_at = table.Column(type: "timestamp with time zone", nullable: false), modified_at = table.Column(type: "timestamp with time zone", nullable: true), deleted = table.Column(type: "boolean", nullable: false), user_id = table.Column(type: "uuid", nullable: true), tenant_id = table.Column(type: "uuid", nullable: true), modified_by_id = table.Column(type: "uuid", nullable: true), created_by_id = table.Column(type: "uuid", nullable: true), deleted_by_id = table.Column(type: "uuid", nullable: true) }, constraints: table => { table.PrimaryKey("pk_projects", x => x.id); }); migrationBuilder.CreateTable( name: "customers", columns: table => new { id = table.Column(type: "uuid", nullable: false), customer_number = table.Column(type: "text", nullable: true), name = table.Column(type: "text", nullable: true), description = table.Column(type: "text", nullable: true), address1 = table.Column(type: "text", nullable: true), address2 = table.Column(type: "text", nullable: true), postal_code = table.Column(type: "text", nullable: true), postal_city = table.Column(type: "text", nullable: true), country = table.Column(type: "text", nullable: true), phone = table.Column(type: "text", nullable: true), email = table.Column(type: "text", nullable: true), vat_number = table.Column(type: "text", nullable: true), org_number = table.Column(type: "text", nullable: true), default_reference = table.Column(type: "text", nullable: true), website = table.Column(type: "text", nullable: true), currency = table.Column(type: "text", nullable: true), project_id = table.Column(type: "uuid", nullable: true), created_at = table.Column(type: "timestamp with time zone", nullable: false), modified_at = table.Column(type: "timestamp with time zone", nullable: true), deleted = table.Column(type: "boolean", nullable: false), user_id = table.Column(type: "uuid", nullable: true), tenant_id = table.Column(type: "uuid", nullable: true), modified_by_id = table.Column(type: "uuid", nullable: true), created_by_id = table.Column(type: "uuid", nullable: true), deleted_by_id = table.Column(type: "uuid", nullable: true) }, constraints: table => { table.PrimaryKey("pk_customers", x => x.id); table.ForeignKey( name: "fk_customers_projects_project_id", column: x => x.project_id, principalTable: "projects", principalColumn: "id"); table.ForeignKey( name: "fk_customers_users_user_id", column: x => x.user_id, principalTable: "users", principalColumn: "id"); }); migrationBuilder.CreateTable( name: "project_labels", columns: table => new { id = table.Column(type: "uuid", nullable: false), value = table.Column(type: "text", nullable: true), color = table.Column(type: "text", nullable: true), project_id = table.Column(type: "uuid", nullable: true), created_at = table.Column(type: "timestamp with time zone", nullable: false), modified_at = table.Column(type: "timestamp with time zone", nullable: true), deleted = table.Column(type: "boolean", nullable: false), user_id = table.Column(type: "uuid", nullable: true), tenant_id = table.Column(type: "uuid", nullable: true), modified_by_id = table.Column(type: "uuid", nullable: true), created_by_id = table.Column(type: "uuid", nullable: true), deleted_by_id = table.Column(type: "uuid", nullable: true) }, constraints: table => { table.PrimaryKey("pk_project_labels", x => x.id); table.ForeignKey( name: "fk_project_labels_projects_project_id", column: x => x.project_id, principalTable: "projects", principalColumn: "id"); }); migrationBuilder.CreateTable( name: "project_member", columns: table => new { id = table.Column(type: "uuid", nullable: false), project_id = table.Column(type: "uuid", nullable: true), user_id = table.Column(type: "uuid", nullable: true), role = table.Column(type: "integer", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false), modified_at = table.Column(type: "timestamp with time zone", nullable: true), deleted = table.Column(type: "boolean", nullable: false) }, constraints: table => { table.PrimaryKey("pk_project_member", x => x.id); table.ForeignKey( name: "fk_project_member_projects_project_id", column: x => x.project_id, principalTable: "projects", principalColumn: "id"); table.ForeignKey( name: "fk_project_member_users_user_id", column: x => x.user_id, principalTable: "users", principalColumn: "id"); }); migrationBuilder.CreateTable( name: "customer_contacts", columns: table => new { id = table.Column(type: "uuid", nullable: false), customer_id = table.Column(type: "uuid", nullable: true), first_name = table.Column(type: "text", nullable: true), last_name = table.Column(type: "text", nullable: true), email = table.Column(type: "text", nullable: true), phone = table.Column(type: "text", nullable: true), work_title = table.Column(type: "text", nullable: true), note = table.Column(type: "text", nullable: true), created_at = table.Column(type: "timestamp with time zone", nullable: false), modified_at = table.Column(type: "timestamp with time zone", nullable: true), deleted = table.Column(type: "boolean", nullable: false), user_id = table.Column(type: "uuid", nullable: true), tenant_id = table.Column(type: "uuid", nullable: true), modified_by_id = table.Column(type: "uuid", nullable: true), created_by_id = table.Column(type: "uuid", nullable: true), deleted_by_id = table.Column(type: "uuid", nullable: true) }, constraints: table => { table.PrimaryKey("pk_customer_contacts", x => x.id); table.ForeignKey( name: "fk_customer_contacts_customers_customer_id", column: x => x.customer_id, principalTable: "customers", principalColumn: "id"); }); migrationBuilder.CreateTable( name: "customer_customer_group", columns: table => new { customers_id = table.Column(type: "uuid", nullable: false), groups_id = table.Column(type: "uuid", nullable: false) }, constraints: table => { table.PrimaryKey("pk_customer_customer_group", x => new { x.customers_id, x.groups_id }); table.ForeignKey( name: "fk_customer_customer_group_customer_groups_groups_id", column: x => x.groups_id, principalTable: "customer_groups", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_customer_customer_group_customers_customers_id", column: x => x.customers_id, principalTable: "customers", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "customer_events", columns: table => new { id = table.Column(type: "uuid", nullable: false), customer_id = table.Column(type: "uuid", nullable: true), title = table.Column(type: "text", nullable: true), note = table.Column(type: "text", nullable: true), created_at = table.Column(type: "timestamp with time zone", nullable: false), modified_at = table.Column(type: "timestamp with time zone", nullable: true), deleted = table.Column(type: "boolean", nullable: false), user_id = table.Column(type: "uuid", nullable: true), tenant_id = table.Column(type: "uuid", nullable: true), modified_by_id = table.Column(type: "uuid", nullable: true), created_by_id = table.Column(type: "uuid", nullable: true), deleted_by_id = table.Column(type: "uuid", nullable: true) }, constraints: table => { table.PrimaryKey("pk_customer_events", x => x.id); table.ForeignKey( name: "fk_customer_events_customers_customer_id", column: x => x.customer_id, principalTable: "customers", principalColumn: "id"); }); migrationBuilder.CreateIndex( name: "ix_customer_contacts_customer_id", table: "customer_contacts", column: "customer_id"); migrationBuilder.CreateIndex( name: "ix_customer_customer_group_groups_id", table: "customer_customer_group", column: "groups_id"); migrationBuilder.CreateIndex( name: "ix_customer_events_customer_id", table: "customer_events", column: "customer_id"); migrationBuilder.CreateIndex( name: "ix_customers_project_id", table: "customers", column: "project_id"); migrationBuilder.CreateIndex( name: "ix_customers_user_id", table: "customers", column: "user_id"); migrationBuilder.CreateIndex( name: "ix_project_labels_project_id", table: "project_labels", column: "project_id"); migrationBuilder.CreateIndex( name: "ix_project_member_project_id", table: "project_member", column: "project_id"); migrationBuilder.CreateIndex( name: "ix_project_member_user_id", table: "project_member", column: "user_id"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "customer_contacts"); migrationBuilder.DropTable( name: "customer_customer_group"); migrationBuilder.DropTable( name: "customer_events"); migrationBuilder.DropTable( name: "project_labels"); migrationBuilder.DropTable( name: "project_member"); migrationBuilder.DropTable( name: "customer_groups"); migrationBuilder.DropTable( name: "customers"); migrationBuilder.DropTable( name: "projects"); } } }