diff options
Diffstat (limited to 'code/api/src/Migrations/20221030080515_InitialProjectAndCustomer.cs')
| -rw-r--r-- | code/api/src/Migrations/20221030080515_InitialProjectAndCustomer.cs | 304 |
1 files changed, 304 insertions, 0 deletions
diff --git a/code/api/src/Migrations/20221030080515_InitialProjectAndCustomer.cs b/code/api/src/Migrations/20221030080515_InitialProjectAndCustomer.cs new file mode 100644 index 0000000..8a856cb --- /dev/null +++ b/code/api/src/Migrations/20221030080515_InitialProjectAndCustomer.cs @@ -0,0 +1,304 @@ +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<Guid>(type: "uuid", nullable: false), + name = table.Column<string>(type: "text", nullable: true), + created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), + modified_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), + deleted = table.Column<bool>(type: "boolean", nullable: false), + user_id = table.Column<Guid>(type: "uuid", nullable: true), + tenant_id = table.Column<Guid>(type: "uuid", nullable: true), + modified_by_id = table.Column<Guid>(type: "uuid", nullable: true), + created_by_id = table.Column<Guid>(type: "uuid", nullable: true), + deleted_by_id = table.Column<Guid>(type: "uuid", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_customer_groups", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "projects", + columns: table => new + { + id = table.Column<Guid>(type: "uuid", nullable: false), + name = table.Column<string>(type: "text", nullable: true), + description = table.Column<string>(type: "text", nullable: true), + start = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), + stop = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), + created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), + modified_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), + deleted = table.Column<bool>(type: "boolean", nullable: false), + user_id = table.Column<Guid>(type: "uuid", nullable: true), + tenant_id = table.Column<Guid>(type: "uuid", nullable: true), + modified_by_id = table.Column<Guid>(type: "uuid", nullable: true), + created_by_id = table.Column<Guid>(type: "uuid", nullable: true), + deleted_by_id = table.Column<Guid>(type: "uuid", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_projects", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "customers", + columns: table => new + { + id = table.Column<Guid>(type: "uuid", nullable: false), + customer_number = table.Column<string>(type: "text", nullable: true), + name = table.Column<string>(type: "text", nullable: true), + description = table.Column<string>(type: "text", nullable: true), + address1 = table.Column<string>(type: "text", nullable: true), + address2 = table.Column<string>(type: "text", nullable: true), + postal_code = table.Column<string>(type: "text", nullable: true), + postal_city = table.Column<string>(type: "text", nullable: true), + country = table.Column<string>(type: "text", nullable: true), + phone = table.Column<string>(type: "text", nullable: true), + email = table.Column<string>(type: "text", nullable: true), + vat_number = table.Column<string>(type: "text", nullable: true), + org_number = table.Column<string>(type: "text", nullable: true), + default_reference = table.Column<string>(type: "text", nullable: true), + website = table.Column<string>(type: "text", nullable: true), + currency = table.Column<string>(type: "text", nullable: true), + project_id = table.Column<Guid>(type: "uuid", nullable: true), + created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), + modified_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), + deleted = table.Column<bool>(type: "boolean", nullable: false), + user_id = table.Column<Guid>(type: "uuid", nullable: true), + tenant_id = table.Column<Guid>(type: "uuid", nullable: true), + modified_by_id = table.Column<Guid>(type: "uuid", nullable: true), + created_by_id = table.Column<Guid>(type: "uuid", nullable: true), + deleted_by_id = table.Column<Guid>(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<Guid>(type: "uuid", nullable: false), + value = table.Column<string>(type: "text", nullable: true), + color = table.Column<string>(type: "text", nullable: true), + project_id = table.Column<Guid>(type: "uuid", nullable: true), + created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), + modified_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), + deleted = table.Column<bool>(type: "boolean", nullable: false), + user_id = table.Column<Guid>(type: "uuid", nullable: true), + tenant_id = table.Column<Guid>(type: "uuid", nullable: true), + modified_by_id = table.Column<Guid>(type: "uuid", nullable: true), + created_by_id = table.Column<Guid>(type: "uuid", nullable: true), + deleted_by_id = table.Column<Guid>(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<Guid>(type: "uuid", nullable: false), + project_id = table.Column<Guid>(type: "uuid", nullable: true), + user_id = table.Column<Guid>(type: "uuid", nullable: true), + role = table.Column<int>(type: "integer", nullable: false), + created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), + modified_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), + deleted = table.Column<bool>(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<Guid>(type: "uuid", nullable: false), + customer_id = table.Column<Guid>(type: "uuid", nullable: true), + first_name = table.Column<string>(type: "text", nullable: true), + last_name = table.Column<string>(type: "text", nullable: true), + email = table.Column<string>(type: "text", nullable: true), + phone = table.Column<string>(type: "text", nullable: true), + work_title = table.Column<string>(type: "text", nullable: true), + note = table.Column<string>(type: "text", nullable: true), + created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), + modified_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), + deleted = table.Column<bool>(type: "boolean", nullable: false), + user_id = table.Column<Guid>(type: "uuid", nullable: true), + tenant_id = table.Column<Guid>(type: "uuid", nullable: true), + modified_by_id = table.Column<Guid>(type: "uuid", nullable: true), + created_by_id = table.Column<Guid>(type: "uuid", nullable: true), + deleted_by_id = table.Column<Guid>(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<Guid>(type: "uuid", nullable: false), + groups_id = table.Column<Guid>(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<Guid>(type: "uuid", nullable: false), + customer_id = table.Column<Guid>(type: "uuid", nullable: true), + title = table.Column<string>(type: "text", nullable: true), + note = table.Column<string>(type: "text", nullable: true), + created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), + modified_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), + deleted = table.Column<bool>(type: "boolean", nullable: false), + user_id = table.Column<Guid>(type: "uuid", nullable: true), + tenant_id = table.Column<Guid>(type: "uuid", nullable: true), + modified_by_id = table.Column<Guid>(type: "uuid", nullable: true), + created_by_id = table.Column<Guid>(type: "uuid", nullable: true), + deleted_by_id = table.Column<Guid>(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"); + } + } +} |
