-- --------------------------------------------------------
-- Host:                         127.0.0.1
-- Wersja serwera:               5.7.31 - MySQL Community Server (GPL)
-- Serwer OS:                    Linux
-- HeidiSQL Wersja:              11.2.0.6213
-- --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;


-- Zrzut struktury bazy danych bop
CREATE DATABASE IF NOT EXISTS `bop` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_polish_ci */;
USE `bop`;

-- Zrzut struktury tabela bop.achievements
CREATE TABLE IF NOT EXISTS `achievements` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `points` decimal(10,2) DEFAULT NULL,
  `achievement_type_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `confirmed_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `not_read_reports_count` int(11) DEFAULT NULL,
  `happen_at` datetime DEFAULT NULL,
  `publi_id` int(11) DEFAULT NULL,
  `achievement_year` smallint(6) DEFAULT NULL,
  `archived` tinyint(1) DEFAULT '0',
  `unit_id` int(11) DEFAULT NULL,
  `accept_import` tinyint(1) DEFAULT '1',
  `points_comment` text COLLATE utf8_unicode_ci,
  `status` int(11) DEFAULT '0',
  `rate_period_id` int(11) DEFAULT NULL,
  `partial_points` decimal(10,2) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `index_achievements_on_achievement_type_id` (`achievement_type_id`),
  KEY `index_achievements_on_user_id` (`user_id`),
  KEY `index_achievements_on_deleted_at` (`deleted_at`),
  KEY `index_achievements_on_confirmed_at` (`confirmed_at`),
  KEY `index_achievements_on_publi_id` (`publi_id`)
) ENGINE=InnoDB AUTO_INCREMENT=433204 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.achievement_comments
CREATE TABLE IF NOT EXISTS `achievement_comments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `achievement_id` int(11) DEFAULT NULL,
  `content` text COLLATE utf8_unicode_ci,
  `status` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `feedback_id` int(11) DEFAULT NULL,
  `feedback_note` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `index_achievement_comments_on_user_id` (`user_id`),
  KEY `index_achievement_comments_on_achievement_id` (`achievement_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1544 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.achievement_files
CREATE TABLE IF NOT EXISTS `achievement_files` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `achievement_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `file_file_name` varchar(255) COLLATE utf8_polish_ci DEFAULT NULL,
  `file_content_type` varchar(255) COLLATE utf8_polish_ci DEFAULT NULL,
  `file_file_size` int(11) DEFAULT NULL,
  `file_updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17689 DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.achievement_types
CREATE TABLE IF NOT EXISTS `achievement_types` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `default_points` decimal(10,2) DEFAULT NULL,
  `group` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
  `subgroup` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `label_format` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=191 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.activities
CREATE TABLE IF NOT EXISTS `activities` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `trackable_id` int(11) DEFAULT NULL,
  `trackable_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `owner_id` int(11) DEFAULT NULL,
  `owner_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `parameters` text COLLATE utf8_unicode_ci,
  `recipient_id` int(11) DEFAULT NULL,
  `recipient_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `index_activities_on_trackable_id_and_trackable_type` (`trackable_id`,`trackable_type`),
  KEY `index_activities_on_owner_id_and_owner_type` (`owner_id`,`owner_type`),
  KEY `index_activities_on_recipient_id_and_recipient_type` (`recipient_id`,`recipient_type`)
) ENGINE=InnoDB AUTO_INCREMENT=474137 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.api_keys
CREATE TABLE IF NOT EXISTS `api_keys` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `access_token` varchar(255) COLLATE utf8_polish_ci DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.errors
CREATE TABLE IF NOT EXISTS `errors` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `content` text COLLATE utf8_unicode_ci,
  `active` tinyint(1) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.fields
CREATE TABLE IF NOT EXISTS `fields` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `default` text COLLATE utf8_unicode_ci,
  `values` text COLLATE utf8_unicode_ci,
  `validations` text COLLATE utf8_unicode_ci,
  `list` tinyint(1) DEFAULT NULL,
  `achievement_type_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `reference_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `marc_value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `idx` int(11) DEFAULT '1',
  `values_points` text COLLATE utf8_unicode_ci,
  `is_link` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `index_fields_on_achievement_type_id` (`achievement_type_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1533 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.field_values
CREATE TABLE IF NOT EXISTS `field_values` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `value` text COLLATE utf8_unicode_ci,
  `field_id` int(11) DEFAULT NULL,
  `achievement_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `value_points` decimal(10,0) DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `index_field_values_on_field_id` (`field_id`),
  KEY `index_field_values_on_achievement_id` (`achievement_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4703378 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.groups
CREATE TABLE IF NOT EXISTS `groups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_polish_ci DEFAULT NULL,
  `achievement_type_ids` text COLLATE utf8_polish_ci,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.job_infos
CREATE TABLE IF NOT EXISTS `job_infos` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `job_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `employed_at` date DEFAULT NULL,
  `job_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `job_started_at` date DEFAULT NULL,
  `supervisor_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `mile_stones` text COLLATE utf8_unicode_ci,
  PRIMARY KEY (`id`),
  KEY `index_job_infos_on_user_id` (`user_id`),
  KEY `index_job_infos_on_supervisor_id` (`supervisor_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1521 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.publi_syncs
CREATE TABLE IF NOT EXISTS `publi_syncs` (
  `publi_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `modified_at` datetime DEFAULT NULL,
  UNIQUE KEY `index_publi_syncs_on_publi_id` (`publi_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.rate_periods
CREATE TABLE IF NOT EXISTS `rate_periods` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `date_start` datetime DEFAULT NULL,
  `date_end` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.schema_migrations
CREATE TABLE IF NOT EXISTS `schema_migrations` (
  `version` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  UNIQUE KEY `unique_schema_migrations` (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.sessions
CREATE TABLE IF NOT EXISTS `sessions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `session_id` varchar(255) COLLATE utf8_polish_ci NOT NULL,
  `data` text COLLATE utf8_polish_ci,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `index_sessions_on_session_id` (`session_id`),
  KEY `index_sessions_on_updated_at` (`updated_at`)
) ENGINE=InnoDB AUTO_INCREMENT=602201 DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.surveys
CREATE TABLE IF NOT EXISTS `surveys` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `proposals` text COLLATE utf8_unicode_ci,
  `supervisor_opinion` text COLLATE utf8_unicode_ci,
  `jury_opinion` text COLLATE utf8_unicode_ci,
  `opinion` tinyint(1) DEFAULT NULL,
  `other_fields` text COLLATE utf8_unicode_ci,
  `archived` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `index_surveys_on_user_id` (`user_id`),
  KEY `index_surveys_on_deleted_at` (`deleted_at`)
) ENGINE=InnoDB AUTO_INCREMENT=2913 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.tinymce_folders
CREATE TABLE IF NOT EXISTS `tinymce_folders` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `parent_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `index_tinymce_folders_on_parent_id` (`parent_id`),
  KEY `index_tinymce_folders_on_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.tinymce_uploads
CREATE TABLE IF NOT EXISTS `tinymce_uploads` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `file_file_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `file_content_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `file_file_size` int(11) DEFAULT NULL,
  `file_updated_at` datetime DEFAULT NULL,
  `folder_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `index_tinymce_uploads_on_folder_id` (`folder_id`),
  KEY `index_tinymce_uploads_on_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.units
CREATE TABLE IF NOT EXISTS `units` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `parent_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `subunits_count` int(11) DEFAULT '0',
  `deleted_at` datetime DEFAULT NULL,
  `real_created_at` date DEFAULT NULL,
  `real_deleted_at` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `index_units_on_parent_id` (`parent_id`)
) ENGINE=InnoDB AUTO_INCREMENT=528 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.unit_names
CREATE TABLE IF NOT EXISTS `unit_names` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `unit_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `index_unit_names_on_unit_id` (`unit_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.unit_rate_periods
CREATE TABLE IF NOT EXISTS `unit_rate_periods` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `unit_id` int(11) DEFAULT NULL,
  `rate_period_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=469 DEFAULT CHARSET=utf8;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.uploaded_files
CREATE TABLE IF NOT EXISTS `uploaded_files` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.users
CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `encrypted_password` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `remember_created_at` datetime DEFAULT NULL,
  `sign_in_count` int(11) DEFAULT '0',
  `current_sign_in_at` datetime DEFAULT NULL,
  `last_sign_in_at` datetime DEFAULT NULL,
  `current_sign_in_ip` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `last_sign_in_ip` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `roles_mask` bigint(20) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `first_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `last_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `unit_id` int(11) DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `publi_id` int(11) DEFAULT NULL,
  `reset_password_token` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `reset_password_sent_at` datetime DEFAULT NULL,
  `unarchived_at` datetime DEFAULT NULL,
  `send_achievement_error` tinyint(1) DEFAULT '0',
  `moderated_unit_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `index_users_on_email` (`email`),
  KEY `index_users_on_unit_id` (`unit_id`),
  KEY `index_users_on_deleted_at` (`deleted_at`)
) ENGINE=InnoDB AUTO_INCREMENT=3439 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela bop.user_units
CREATE TABLE IF NOT EXISTS `user_units` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `unit_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `index_user_units_on_user_id` (`user_id`),
  KEY `index_user_units_on_unit_id` (`unit_id`)
) ENGINE=InnoDB AUTO_INCREMENT=499 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Eksport danych został odznaczony.

/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;
