using AsbCloudDb.Model; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using System; using System.Collections.Generic; namespace AsbCloudDb.Migrations { public partial class Init : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:adminpack", ",,"); migrationBuilder.CreateTable( name: "t_company_type", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), caption = table.Column(type: "character varying(255)", maxLength: 255, nullable: true) }, constraints: table => { table.PrimaryKey("PK_t_company_type", x => x.id); }); migrationBuilder.CreateTable( name: "t_deposit", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), caption = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), latitude = table.Column(type: "double precision", nullable: true), longitude = table.Column(type: "double precision", nullable: true) }, constraints: table => { table.PrimaryKey("PK_t_deposit", x => x.id); }, comment: "Месторождение"); migrationBuilder.CreateTable( name: "t_file_category", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), name = table.Column(type: "text", nullable: true, comment: "Название категории"), short_name = table.Column(type: "text", nullable: true, comment: "Короткое название категории") }, constraints: table => { table.PrimaryKey("PK_t_file_category", x => x.id); }, comment: "Категории файлов"); migrationBuilder.CreateTable( name: "t_measure_category", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), name = table.Column(type: "text", nullable: true, comment: "Название категории"), short_name = table.Column(type: "text", nullable: true, comment: "Короткое название категории") }, constraints: table => { table.PrimaryKey("PK_t_measure_category", x => x.id); }, comment: "Категория последних данных"); migrationBuilder.CreateTable( name: "t_telemetry", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), remote_uid = table.Column(type: "text", nullable: true, comment: "Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв."), info = table.Column(type: "jsonb", nullable: true, comment: "Информация с панели о скважине") }, constraints: table => { table.PrimaryKey("PK_t_telemetry", x => x.id); }, comment: "таблица привязки телеметрии от комплектов к конкретной скважине."); migrationBuilder.CreateTable( name: "t_user_role", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), caption = table.Column(type: "character varying(255)", maxLength: 255, nullable: true, comment: "Название") }, constraints: table => { table.PrimaryKey("PK_t_user_role", x => x.id); }, comment: "Роли пользователей в системе"); migrationBuilder.CreateTable( name: "t_well_operation_category", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), name = table.Column(type: "text", nullable: true, comment: "Название категории операции"), code = table.Column(type: "integer", nullable: false, comment: "Код операции") }, constraints: table => { table.PrimaryKey("PK_t_well_operation_category", x => x.id); }, comment: "Справочник операций на скважине"); migrationBuilder.CreateTable( name: "t_well_section_type", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), caption = table.Column(type: "character varying(255)", maxLength: 255, nullable: true, comment: "Название") }, constraints: table => { table.PrimaryKey("PK_t_well_section_type", x => x.id); }, comment: "конструкция секции скважины"); migrationBuilder.CreateTable( name: "t_well_type", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), caption = table.Column(type: "character varying(255)", maxLength: 255, nullable: true, comment: "Название") }, constraints: table => { table.PrimaryKey("PK_t_well_type", x => x.id); }, comment: "конструкция скважины"); migrationBuilder.CreateTable( name: "t_company", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), caption = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), id_company_type = table.Column(type: "integer", maxLength: 255, nullable: false, comment: "вид деятельности") }, constraints: table => { table.PrimaryKey("PK_t_company", x => x.id); table.ForeignKey( name: "FK_t_company_t_company_type_id_company_type", column: x => x.id_company_type, principalTable: "t_company_type", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "t_cluster", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), caption = table.Column(type: "character varying(255)", maxLength: 255, nullable: true, comment: "Название"), id_deposit = table.Column(type: "integer", nullable: true), latitude = table.Column(type: "double precision", nullable: true), longitude = table.Column(type: "double precision", nullable: true) }, constraints: table => { table.PrimaryKey("PK_t_cluster", x => x.id); table.ForeignKey( name: "t_cluster_t_deposit_id_fk", column: x => x.id_deposit, principalTable: "t_deposit", principalColumn: "id", onDelete: ReferentialAction.Restrict); }, comment: "Кусты"); migrationBuilder.CreateTable( name: "t_data_saub_base", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), id_telemetry = table.Column(type: "integer", nullable: false), date = table.Column(type: "timestamp with time zone", nullable: false, comment: "'2021-10-19 18:23:54+05'"), mode = table.Column(type: "integer", nullable: true, comment: "Режим САУБ"), id_user = table.Column(type: "integer", nullable: true, comment: "Пользователь САУБ"), well_depth = table.Column(type: "double precision", nullable: true, comment: "Глубина забоя"), bit_depth = table.Column(type: "double precision", nullable: true, comment: "Положение инструмента"), block_position = table.Column(type: "double precision", nullable: true, comment: "Высота талевого блока"), block_position_min = table.Column(type: "double precision", nullable: true, comment: "Талевый блок. Мин положение"), block_position_max = table.Column(type: "double precision", nullable: true, comment: "Талевый блок. Макс положение"), block_speed = table.Column(type: "double precision", nullable: true, comment: "Скорость талевого блока"), block_speed_sp = table.Column(type: "double precision", nullable: true, comment: "Скорости талевого блока. Задание"), block_speed_sp_rotor = table.Column(type: "double precision", nullable: true, comment: "Талевый блок. Задание скорости для роторного бурения"), block_speed_sp_slide = table.Column(type: "double precision", nullable: true, comment: "Талевый блок. Задание скорости для режима слайда"), block_speed_sp_develop = table.Column(type: "double precision", nullable: true, comment: "Талевый блок. Задание скорости для проработки"), pressure = table.Column(type: "double precision", nullable: true, comment: "Давление"), pressure_idle = table.Column(type: "double precision", nullable: true, comment: "Давление. Холостой ход"), pressure_sp = table.Column(type: "double precision", nullable: true, comment: "Давление. Задание"), pressure_sp_rotor = table.Column(type: "double precision", nullable: true, comment: "Давление. Задание для роторного бурения"), pressure_sp_slide = table.Column(type: "double precision", nullable: true, comment: "Давление. Задание для режима слайда"), pressure_sp_develop = table.Column(type: "double precision", nullable: true, comment: "Давление. Задание для проработки"), pressure_delta_limit_max = table.Column(type: "double precision", nullable: true, comment: "Давление дифф. Аварийное макс."), axial_load = table.Column(type: "double precision", nullable: true, comment: "Осевая нагрузка"), axial_load_sp = table.Column(type: "double precision", nullable: true, comment: "Осевая нагрузка. Задание"), axial_load_limit_max = table.Column(type: "double precision", nullable: true, comment: "Осевая нагрузка. Аварийная макс."), hook_weight = table.Column(type: "double precision", nullable: true, comment: "Вес на крюке"), hook_weight_idle = table.Column(type: "double precision", nullable: true, comment: "Вес на крюке. Холостой ход"), hook_weight_limit_min = table.Column(type: "double precision", nullable: true, comment: "Вес на крюке. Посадка"), hook_weight_limit_max = table.Column(type: "double precision", nullable: true, comment: "Вес на крюке. Затяжка"), rotor_torque = table.Column(type: "double precision", nullable: true, comment: "Момент на роторе"), rotor_torque_idle = table.Column(type: "double precision", nullable: true, comment: "Момент на роторе. Холостой ход"), rotor_torque_sp = table.Column(type: "double precision", nullable: true, comment: "Момент на роторе. Задание"), rotor_torque_limit_max = table.Column(type: "double precision", nullable: true, comment: "Момент на роторе. Аварийный макс."), rotor_speed = table.Column(type: "double precision", nullable: true, comment: "Обороты ротора"), flow = table.Column(type: "double precision", nullable: true, comment: "Расход"), flow_idle = table.Column(type: "double precision", nullable: true, comment: "Расход. Холостой ход"), flow_delta_limit_max = table.Column(type: "double precision", nullable: true, comment: "Расход. Аварийный макс."), id_feed_regulator = table.Column(type: "double precision", nullable: true, comment: "Текущий критерий бурения"), mse_state = table.Column(type: "double precision", nullable: true, comment: "Текущее состояние работы MSE") }, constraints: table => { table.PrimaryKey("PK_t_data_saub_base", x => x.id); table.ForeignKey( name: "t_data_saub_base_t_telemetry_id_fk", column: x => x.id_telemetry, principalTable: "t_telemetry", principalColumn: "id", onDelete: ReferentialAction.Restrict); }, comment: "набор основных данных по SAUB"); migrationBuilder.CreateTable( name: "t_telemetry_event", columns: table => new { id_event = table.Column(type: "integer", nullable: false), id_telemetry = table.Column(type: "integer", nullable: false), id_category = table.Column(type: "integer", nullable: false), message_template = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_t_telemetry_event", x => new { x.id_telemetry, x.id_event }); table.ForeignKey( name: "t_event_t_telemetry_id_fk", column: x => x.id_telemetry, principalTable: "t_telemetry", principalColumn: "id", onDelete: ReferentialAction.Cascade); }, comment: "Справочник событий. События формируют сообщения. Разделено по версиям посылок от телеметрии."); migrationBuilder.CreateTable( name: "t_telemetry_message", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), id_telemetry = table.Column(type: "integer", nullable: false), id_event = table.Column(type: "integer", nullable: false), id_telemetry_user = table.Column(type: "integer", nullable: true, comment: "Пользователь панели отправляющей телеметрию. не пользователь облака."), date = table.Column(type: "timestamp with time zone", nullable: false), arg0 = table.Column(type: "character varying(255)", maxLength: 255, nullable: true, comment: "Аргумент №0 для вставки в шаблон сообщения"), arg1 = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), arg2 = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), arg3 = table.Column(type: "character varying(255)", maxLength: 255, nullable: true) }, constraints: table => { table.PrimaryKey("PK_t_telemetry_message", x => x.id); table.ForeignKey( name: "t_messages_t_telemetry_id_fk", column: x => x.id_telemetry, principalTable: "t_telemetry", principalColumn: "id", onDelete: ReferentialAction.Cascade); }, comment: "Сообщения на буровых"); migrationBuilder.CreateTable( name: "t_telemetry_user", columns: table => new { id_user = table.Column(type: "integer", nullable: false), id_telemetry = table.Column(type: "integer", nullable: false), name = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), surname = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), patronymic = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), level = table.Column(type: "integer", nullable: true) }, constraints: table => { table.PrimaryKey("PK_t_telemetry_user", x => new { x.id_telemetry, x.id_user }); table.ForeignKey( name: "t_telemetry_user_t_telemetry_id_fk", column: x => x.id_telemetry, principalTable: "t_telemetry", principalColumn: "id", onDelete: ReferentialAction.Restrict); }, comment: "Пользователи панели САУБ. Для сообщений."); migrationBuilder.CreateTable( name: "t_telemetry_analysis", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), id_telemetry = table.Column(type: "integer", nullable: false), id_operation = table.Column(type: "integer", nullable: false), unix_date = table.Column(type: "bigint", nullable: false, comment: "Unix timestamp для Linq запросов с вычислением дат"), duration_sec = table.Column(type: "integer", nullable: false, comment: "Кол-во секунд после предыдущей операции"), operation_start_depth = table.Column(type: "double precision", nullable: true, comment: "Глубина, на которой началась операция"), operation_end_depth = table.Column(type: "double precision", nullable: true, comment: "Глубина, на которой закончилась операция"), is_well_depth_increasing = table.Column(type: "boolean", nullable: false, comment: "Глубина забоя увеличивается"), is_well_depth_decreasing = table.Column(type: "boolean", nullable: false, comment: "Глубина забоя не увеличивается"), is_bit_position_increasing = table.Column(type: "boolean", nullable: false, comment: "Долото спускается"), is_bit_position_decreasing = table.Column(type: "boolean", nullable: false, comment: "Долото поднимается"), is_bit_posision_lt_20 = table.Column(type: "boolean", nullable: false, comment: "Положение долота меньше 20м"), is_block_posision_incresing = table.Column(type: "boolean", nullable: false, comment: "Талевый блок спускается"), is_block_posision_decresing = table.Column(type: "boolean", nullable: false, comment: "Талевый блок поднимается"), is_rotor_speed_lt_3 = table.Column(type: "boolean", nullable: false, comment: "Обороты ротора ниже 3"), is_rotor_speed_gt_3 = table.Column(type: "boolean", nullable: false, comment: "Обороты ротора выше 3"), is_pressure_lt_20 = table.Column(type: "boolean", nullable: false, comment: "Давление менее 20"), is_pressure_gt_20 = table.Column(type: "boolean", nullable: false, comment: "Давоение более 20"), is_hook_weight_not_changes = table.Column(type: "boolean", nullable: false, comment: "Вес на крюке не меняется"), is_hook_weight_lt_3 = table.Column(type: "boolean", nullable: false, comment: "Вес на крюке менее 3т") }, constraints: table => { table.PrimaryKey("PK_t_telemetry_analysis", x => x.id); table.ForeignKey( name: "t_analysis_t_operation_id_fk", column: x => x.id_operation, principalTable: "t_well_operation_category", principalColumn: "id", onDelete: ReferentialAction.SetNull); table.ForeignKey( name: "t_analysis_t_telemetry_id_fk", column: x => x.id_telemetry, principalTable: "t_telemetry", principalColumn: "id", onDelete: ReferentialAction.Cascade); }, comment: "События на скважине"); migrationBuilder.CreateTable( name: "t_user", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), id_company = table.Column(type: "integer", nullable: true), id_role = table.Column(type: "integer", nullable: true), login = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), password_hash = table.Column(type: "character varying(255)", maxLength: 255, nullable: true, comment: "соленый хэш пароля.\nпервые 5 символов - соль"), state = table.Column(type: "smallint", nullable: true, comment: "состояние:\n100 - удален"), level = table.Column(type: "integer", nullable: true), name = table.Column(type: "character varying(255)", maxLength: 255, nullable: true, comment: "имя"), surname = table.Column(type: "character varying(255)", maxLength: 255, nullable: true, comment: "фамилия"), patronymic = table.Column(type: "character varying(255)", maxLength: 255, nullable: true, comment: "отчество") }, constraints: table => { table.PrimaryKey("PK_t_user", x => x.id); table.ForeignKey( name: "FK_t_user_t_user_role_id_role", column: x => x.id_role, principalTable: "t_user_role", principalColumn: "id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "t_user_t_company_id_fk", column: x => x.id_company, principalTable: "t_company", principalColumn: "id", onDelete: ReferentialAction.Restrict); }, comment: "Пользователи облака"); migrationBuilder.CreateTable( name: "t_well", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), caption = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), id_cluster = table.Column(type: "integer", nullable: true), id_telemetry = table.Column(type: "integer", nullable: true), id_well_type = table.Column(type: "integer", nullable: true), latitude = table.Column(type: "double precision", nullable: true), longitude = table.Column(type: "double precision", nullable: true) }, constraints: table => { table.PrimaryKey("PK_t_well", x => x.id); table.ForeignKey( name: "FK_t_well_t_well_type_id_well_type", column: x => x.id_well_type, principalTable: "t_well_type", principalColumn: "id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "t_well_t_cluster_id_fk", column: x => x.id_cluster, principalTable: "t_cluster", principalColumn: "id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "t_well_t_telemetry_id_fk", column: x => x.id_telemetry, principalTable: "t_telemetry", principalColumn: "id", onDelete: ReferentialAction.Restrict); }, comment: "скважины"); migrationBuilder.CreateTable( name: "t_file_info", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), id_well = table.Column(type: "integer", nullable: false, comment: "id скважины"), id_author = table.Column(type: "integer", nullable: true, comment: "Id пользователя, загрузившего файл"), id_category = table.Column(type: "integer", nullable: false, comment: "id категории файла"), name = table.Column(type: "text", nullable: true, comment: "Название файла"), date = table.Column(type: "timestamp with time zone", nullable: false), file_size = table.Column(type: "bigint", nullable: false, comment: "Размер файла"), is_deleted = table.Column(type: "boolean", nullable: false, comment: "Удален ли файл") }, constraints: table => { table.PrimaryKey("PK_t_file_info", x => x.id); table.ForeignKey( name: "FK_t_file_info_t_file_category_id_category", column: x => x.id_category, principalTable: "t_file_category", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_t_file_info_t_user_id_author", column: x => x.id_author, principalTable: "t_user", principalColumn: "id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_t_file_info_t_well_id_well", column: x => x.id_well, principalTable: "t_well", principalColumn: "id", onDelete: ReferentialAction.Cascade); }, comment: "Файлы всех категорий"); migrationBuilder.CreateTable( name: "t_measure", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), id_well = table.Column(type: "integer", nullable: false, comment: "id скважины"), id_category = table.Column(type: "integer", nullable: false, comment: "id категории"), timestamp = table.Column(type: "timestamp without time zone", nullable: false, comment: "время добавления"), data = table.Column>(type: "jsonb", nullable: true, comment: "Данные таблицы последних данных"), is_deleted = table.Column(type: "boolean", nullable: false, comment: "Пометка удаленным") }, constraints: table => { table.PrimaryKey("PK_t_measure", x => x.id); table.ForeignKey( name: "FK_t_measure_t_measure_category_id_category", column: x => x.id_category, principalTable: "t_measure_category", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_t_measure_t_well_id_well", column: x => x.id_well, principalTable: "t_well", principalColumn: "id", onDelete: ReferentialAction.Cascade); }, comment: "Таблица c данными для вкладки 'Последние данные'"); migrationBuilder.CreateTable( name: "t_relation_company_well", columns: table => new { id_well = table.Column(type: "integer", nullable: false), id_company = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_t_relation_company_well", x => new { x.id_company, x.id_well }); table.ForeignKey( name: "t_relation_company_well_t_company_id_fk", column: x => x.id_company, principalTable: "t_company", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "t_relation_company_well_t_well_id_fk", column: x => x.id_well, principalTable: "t_well", principalColumn: "id", onDelete: ReferentialAction.Cascade); }, comment: "отношение скважин и компаний"); migrationBuilder.CreateTable( name: "t_well_operation", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), id_well = table.Column(type: "integer", nullable: false, comment: "Id скважины"), id_well_section_type = table.Column(type: "integer", nullable: false, comment: "Id тип секции скважины"), id_category = table.Column(type: "integer", nullable: false, comment: "Id категории операции"), id_type = table.Column(type: "integer", nullable: false, comment: "0 = План или 1 = Факт"), depth = table.Column(type: "double precision", nullable: false, comment: "Глубина, на которой производилась операция"), date = table.Column(type: "timestamp without time zone", nullable: false, comment: "Дата начала операции"), duration_hours = table.Column(type: "double precision", nullable: false, comment: "Продолжительность в часах"), category_info = table.Column(type: "text", nullable: true, comment: "Доп. информация к выбраной категории"), comment = table.Column(type: "text", nullable: true, comment: "Комментарий") }, constraints: table => { table.PrimaryKey("PK_t_well_operation", x => x.id); table.ForeignKey( name: "FK_t_well_operation_t_well_id_well", column: x => x.id_well, principalTable: "t_well", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_t_well_operation_t_well_operation_category_id_category", column: x => x.id_category, principalTable: "t_well_operation_category", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_t_well_operation_t_well_section_type_id_well_section_type", column: x => x.id_well_section_type, principalTable: "t_well_section_type", principalColumn: "id", onDelete: ReferentialAction.Cascade); }, comment: "Данные по операциям на скважине"); migrationBuilder.CreateTable( name: "t_report_property", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), id_well = table.Column(type: "integer", nullable: false, comment: "id скважины"), id_file = table.Column(type: "integer", nullable: false, comment: "id файла-родителя"), begin = table.Column(type: "timestamp with time zone", nullable: false), end = table.Column(type: "timestamp with time zone", nullable: false, comment: "timestamp with time zone"), step = table.Column(type: "integer", nullable: false, comment: "размер шага в секундах"), format = table.Column(type: "integer", nullable: false, comment: "Формат отчета") }, constraints: table => { table.PrimaryKey("PK_t_report_property", x => x.id); table.ForeignKey( name: "FK_t_report_property_t_file_info_id_file", column: x => x.id_file, principalTable: "t_file_info", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_t_report_property_t_well_id_well", column: x => x.id_well, principalTable: "t_well", principalColumn: "id", onDelete: ReferentialAction.Cascade); }, comment: "Отчеты с данными по буровым"); migrationBuilder.InsertData( table: "t_company_type", columns: new[] { "id", "caption" }, values: new object[,] { { 1, "Недрапользователь" }, { 2, "Буровой подрядчик" }, { 3, "Сервис автоматизации бурения" } }); migrationBuilder.InsertData( table: "t_file_category", columns: new[] { "id", "name", "short_name" }, values: new object[,] { { 13, "Программа бурения, части", "ПБч" }, { 12, "Рапорт", "report" }, { 11, "Последние данные ННБ", "nnbLastData" }, { 10, "Последние данные Шламограммы", "mudLastData" }, { 9, "Последний замер бурового раствора ФАКТ", "fluidFactLastData" }, { 8, "Последний замер бурового раствора ПЛАН", "fluidPlanLastData" }, { 6, "Супервайзер", "supervisor" }, { 14, "Программа бурения", "ПБ" }, { 5, "Документы по скважине", "wellDocuments" }, { 4, "ГТИ", "gti" }, { 3, "ННБ", "nnb" }, { 2, "Цементирование", "cement" }, { 1, "Растворный сервис", "fluidService" }, { 7, "Мастер", "master" } }); migrationBuilder.InsertData( table: "t_measure_category", columns: new[] { "id", "name", "short_name" }, values: new object[,] { { 3, "ННБ", "ННБ" }, { 2, "Шламограмма", "Шламограмма" }, { 1, "Показатели бурового раствора", "Раствор" } }); migrationBuilder.InsertData( table: "t_user_role", columns: new[] { "id", "caption" }, values: new object[,] { { 1, "Администратор" }, { 2, "Пользователь" } }); migrationBuilder.InsertData( table: "t_well_operation_category", columns: new[] { "id", "code", "name" }, values: new object[,] { { 1031, 0, "Ремонт" }, { 1030, 0, "Разбуривание тех.оснастки" }, { 1029, 0, "Прокачка пачек" }, { 1028, 0, "Промежуточная промывка" }, { 1027, 0, "Промывка" }, { 1026, 0, "Разборка КНБК" }, { 1024, 0, "Подготовительные работы" }, { 1032, 0, "Спуск инструмента" }, { 1023, 0, "Сборка инструмента" }, { 1022, 0, "Обратная проработка" }, { 1021, 0, "Подъем инструмента с промывкой" }, { 1020, 0, "Подъем инструмента" }, { 1019, 0, "Перетяжка тальканата" }, { 1025, 0, "Сборка КНБК" }, { 1033, 0, "Спуск инструмента с промывкой" }, { 1044, 0, "ВМР" }, { 1035, 0, "Принудительная проработка" }, { 1036, 0, "Спуск обсадной колонны" }, { 1037, 0, "Тех СПО-подъем" }, { 1038, 0, "Тех СПО-спуск" }, { 1039, 0, "Техническое обслуживание" }, { 1040, 0, "Цементаж" }, { 1041, 0, "Шаблонировка ствола" }, { 1042, 0, "Геологическое осложнение" }, { 1043, 0, "НПВ" }, { 1018, 0, "Перетяжка талевого каната" }, { 1045, 0, "Прочее" }, { 1046, 0, "Спуск КНБК" }, { 1047, 0, "Подъем КНБК" }, { 1048, 0, "Спуск ОК" }, { 1034, 0, "Прямая проработка" }, { 1017, 0, "Перезапись каротажа" }, { 1009, 0, "Оборудование устья" }, { 1015, 0, "Опрессовка ВЗД" }, { 1, 0, "Невозможно определить операцию" }, { 2, 0, "Роторное бурение" }, { 3, 0, "Слайдирование" }, { 4, 0, "Подъем с проработкой" }, { 5, 0, "Спуск с проработкой" }, { 6, 0, "Подъем с промывкой" }, { 7, 0, "Спуск с промывкой" }, { 8, 0, "Спуск в скважину" }, { 9, 0, "Спуск с вращением" }, { 10, 0, "Подъем из скважины" }, { 11, 0, "Подъем с вращением" }, { 12, 0, "Промывка в покое" }, { 1016, 0, "Перевод скв на другой тип промывочной жидкости" }, { 14, 0, "Удержание в клиньях" }, { 15, 0, "Неподвижное состояние" }, { 13, 0, "Промывка с вращением" }, { 17, 0, "На поверхности" }, { 1014, 0, "Опресовка Ц.К." }, { 1013, 0, "Опрессовка ПВО" }, { 1012, 0, "Окончание цикла строительства скважины" }, { 16, 0, "Вращение без циркуляции" }, { 1010, 0, "ОЗЦ" }, { 1008, 0, "ОЗЦ" }, { 1011, 0, "Начало цикла строительства скважины" }, { 1006, 0, "Установка ФА" }, { 1005, 0, "Демонтаж ПВО" }, { 1004, 0, "Монтаж ПВО" }, { 1003, 0, "ГФР" }, { 1002, 0, "ГИС" }, { 1001, 0, "Бурение в интервале" }, { 1007, 0, "Оборудование устья" } }); migrationBuilder.InsertData( table: "t_well_section_type", columns: new[] { "id", "caption" }, values: new object[,] { { 1, "Пилотный ствол" }, { 2, "Направление" }, { 3, "Кондуктор" }, { 4, "Эксплуатационная колонна" }, { 5, "Транспортный ствол" }, { 6, "Хвостовик" } }); migrationBuilder.InsertData( table: "t_well_type", columns: new[] { "id", "caption" }, values: new object[,] { { 1, "Наклонно-направленная" }, { 2, "Горизонтальная" } }); migrationBuilder.InsertData( table: "t_company", columns: new[] { "id", "caption", "id_company_type" }, values: new object[] { 1, "ООО \"АСБ\"", 3 }); migrationBuilder.InsertData( table: "t_user", columns: new[] { "id", "id_company", "id_role", "level", "login", "name", "password_hash", "patronymic", "state", "surname" }, values: new object[] { 1, 1, 1, 2147483647, "dev", "Разработчик", "Vlcj|4fa529103dde7ff72cfe76185f344d4aa87931f8e1b2044e8a7739947c3d18923464eaad93843e4f809c5e126d013072", null, null, null }); migrationBuilder.CreateIndex( name: "IX_t_cluster_id_deposit", table: "t_cluster", column: "id_deposit"); migrationBuilder.CreateIndex( name: "IX_t_company_id_company_type", table: "t_company", column: "id_company_type"); migrationBuilder.CreateIndex( name: "IX_t_data_saub_base_id_telemetry", table: "t_data_saub_base", column: "id_telemetry"); migrationBuilder.CreateIndex( name: "IX_t_file_info_id_author", table: "t_file_info", column: "id_author"); migrationBuilder.CreateIndex( name: "IX_t_file_info_id_category", table: "t_file_info", column: "id_category"); migrationBuilder.CreateIndex( name: "IX_t_file_info_id_well", table: "t_file_info", column: "id_well"); migrationBuilder.CreateIndex( name: "IX_t_measure_id_category", table: "t_measure", column: "id_category"); migrationBuilder.CreateIndex( name: "IX_t_measure_id_well", table: "t_measure", column: "id_well"); migrationBuilder.CreateIndex( name: "IX_t_relation_company_well_id_well", table: "t_relation_company_well", column: "id_well"); migrationBuilder.CreateIndex( name: "IX_t_report_property_id_file", table: "t_report_property", column: "id_file"); migrationBuilder.CreateIndex( name: "IX_t_report_property_id_well", table: "t_report_property", column: "id_well"); migrationBuilder.CreateIndex( name: "t_telemetry_remote_uid_index", table: "t_telemetry", column: "remote_uid"); migrationBuilder.CreateIndex( name: "IX_t_telemetry_analysis_id_operation", table: "t_telemetry_analysis", column: "id_operation"); migrationBuilder.CreateIndex( name: "IX_t_telemetry_analysis_id_telemetry", table: "t_telemetry_analysis", column: "id_telemetry"); migrationBuilder.CreateIndex( name: "IX_t_telemetry_message_id_telemetry", table: "t_telemetry_message", column: "id_telemetry"); migrationBuilder.CreateIndex( name: "IX_t_user_id_company", table: "t_user", column: "id_company"); migrationBuilder.CreateIndex( name: "IX_t_user_id_role", table: "t_user", column: "id_role"); migrationBuilder.CreateIndex( name: "IX_t_user_login", table: "t_user", column: "login", unique: true); migrationBuilder.CreateIndex( name: "IX_t_well_id_cluster", table: "t_well", column: "id_cluster"); migrationBuilder.CreateIndex( name: "IX_t_well_id_telemetry", table: "t_well", column: "id_telemetry", unique: true); migrationBuilder.CreateIndex( name: "IX_t_well_id_well_type", table: "t_well", column: "id_well_type"); migrationBuilder.CreateIndex( name: "IX_t_well_operation_date", table: "t_well_operation", column: "date"); migrationBuilder.CreateIndex( name: "IX_t_well_operation_depth", table: "t_well_operation", column: "depth"); migrationBuilder.CreateIndex( name: "IX_t_well_operation_id_category", table: "t_well_operation", column: "id_category"); migrationBuilder.CreateIndex( name: "IX_t_well_operation_id_well", table: "t_well_operation", column: "id_well"); migrationBuilder.CreateIndex( name: "IX_t_well_operation_id_well_section_type", table: "t_well_operation", column: "id_well_section_type"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "t_data_saub_base"); migrationBuilder.DropTable( name: "t_measure"); migrationBuilder.DropTable( name: "t_relation_company_well"); migrationBuilder.DropTable( name: "t_report_property"); migrationBuilder.DropTable( name: "t_telemetry_analysis"); migrationBuilder.DropTable( name: "t_telemetry_event"); migrationBuilder.DropTable( name: "t_telemetry_message"); migrationBuilder.DropTable( name: "t_telemetry_user"); migrationBuilder.DropTable( name: "t_well_operation"); migrationBuilder.DropTable( name: "t_measure_category"); migrationBuilder.DropTable( name: "t_file_info"); migrationBuilder.DropTable( name: "t_well_operation_category"); migrationBuilder.DropTable( name: "t_well_section_type"); migrationBuilder.DropTable( name: "t_file_category"); migrationBuilder.DropTable( name: "t_user"); migrationBuilder.DropTable( name: "t_well"); migrationBuilder.DropTable( name: "t_user_role"); migrationBuilder.DropTable( name: "t_company"); migrationBuilder.DropTable( name: "t_well_type"); migrationBuilder.DropTable( name: "t_cluster"); migrationBuilder.DropTable( name: "t_telemetry"); migrationBuilder.DropTable( name: "t_company_type"); migrationBuilder.DropTable( name: "t_deposit"); } } }