sql stringlengths 6 1.05M |
|---|
-- @testpoint:opengauss关键字disable(非保留),作为视图名
--关键字disable作为视图名,不带引号,创建成功
CREATE or replace VIEW disable AS
SELECT * FROM pg_tablespace WHERE spcname = 'pg_default';
drop view disable;
--关键字disable作为视图名,加双引号,创建成功
CREATE or replace VIEW "disable" AS
SELECT * FROM pg_tablespace WHERE spcname = 'pg_default';
drop VIEW "disable";
--关键字disable作为视图名,加单引号,合理报错
CREATE or replace VIEW 'disable' AS
SELECT * FROM pg_tablespace WHERE spcname = 'pg_default';
--关键字disable作为视图名,加反引号,合理报错
CREATE or replace VIEW `disable` AS
SELECT * FROM pg_tablespace WHERE spcname = 'pg_default';
|
<filename>openGaussBase/testcase/KEYWORDS/and/Opengauss_Function_Keyword_And_Case0027.sql
-- @testpoint:opengauss关键字And(保留),作为序列名
--关键字不带引号-合理报错
drop sequence if exists And;
create sequence And start 100 cache 50;
--关键字带双引号-成功
drop sequence if exists "And";
create sequence "And" start 100 cache 50;
--清理环境
drop sequence "And";
--关键字带单引号-合理报错
drop sequence if exists 'And';
create sequence 'And' start 100 cache 50;
--关键字带反引号-合理报错
drop sequence if exists `And`;
create sequence `And` start 100 cache 50;
|
SELECT
ps.[PRIMARY],
{sensors}
FROM dbo.prozessmessung_schleifen ps
WHERE WARM = {warm}
AND TEACH_ACTIVE = {teach_active}
AND READY = {ready}
AND MA_NR = {ma_nr}
AND WSG_ID = {wsg_id}
AND WZD_ID = {wzd_id}
AND ST_ID = {st_id}
AND AT_ID = {at_id}
AND INSDATE BETWEEN '{start_date}' AND '{end_date}'
|
CREATE DATABASE project;
CREATE TABLE `project`.`detailtable` (
`UID` INT(3) NOT NULL AUTO_INCREMENT,
`NAME` VARCHAR(45) NOT NULL,
`GENDER` VARCHAR(6) NOT NULL,
`DOB` VARCHAR(10) NOT NULL,
`RELIGION` VARCHAR(15) NOT NULL,
`MOTHER_TONGUE` VARCHAR(45) NOT NULL,
PRIMARY KEY (`UID`),
UNIQUE INDEX `UID_UNIQUE` (`UID` ASC));
CREATE TABLE `project`.`idtable` (
`UID` INT(3) NOT NULL AUTO_INCREMENT,
`ID_NUMBER` VARCHAR(30) NOT NULL,
`ID_TYPE` VARCHAR(15) NOT NULL,
PRIMARY KEY (`UID`, `ID_TYPE`),
CONSTRAINT `FK1_UID`
FOREIGN KEY (`UID`)
REFERENCES `project`.`detailtable` (`UID`)
ON DELETE CASCADE
ON UPDATE NO ACTION);
CREATE TABLE `project`.`addresstable` (
`UID` INT(3) NOT NULL AUTO_INCREMENT,
`PINCODE` INT(6) NOT NULL,
`ADDRESS` VARCHAR(120) NOT NULL,
PRIMARY KEY (`UID`, `ADDRESS`),
CONSTRAINT `FK2_UID`
FOREIGN KEY (`UID`)
REFERENCES `project`.`detailtable` (`UID`)
ON DELETE CASCADE
ON UPDATE NO ACTION);
CREATE TABLE `project`.`educationtable` (
`UID` INT(3) NOT NULL AUTO_INCREMENT,
`TEN` INT(1) NOT NULL DEFAULT 0,
`TWE` INT(1) NOT NULL DEFAULT 0,
`UG` INT(1) NOT NULL DEFAULT 0,
`PG` INT(1) NOT NULL DEFAULT 0,
`DR` INT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`UID`),
CONSTRAINT `FK3_UID`
FOREIGN KEY (`UID`)
REFERENCES `project`.`detailtable` (`UID`)
ON DELETE CASCADE
ON UPDATE NO ACTION);
CREATE TABLE `project`.`worktable` (
`UID` INT(3) NOT NULL AUTO_INCREMENT,
`WORK_TYPE` VARCHAR(60) NOT NULL,
PRIMARY KEY (`UID`, `WORK_TYPE`),
CONSTRAINT `FK4_UID`
FOREIGN KEY (`UID`)
REFERENCES `project`.`detailtable` (`UID`)
ON DELETE CASCADE
ON UPDATE NO ACTION);
|
USE SoftUni
SELECT
DepartmentID,
SUM(Salary) AS [TotalSalary]
FROM Employees
GROUP BY DepartmentID
SELECT
DepartmentID,
MIN(Salary) AS [MinimumSalary]
FROM Employees
WHERE DepartmentID IN (2, 5, 7)
AND HireDate > '01/01/2000'
GROUP BY DepartmentID
SELECT * INTO EmployeesSalaryAbove30K
FROM Employees
WHERE Salary > 30000
DELETE FROM EmployeesSalaryAbove30K
WHERE ManagerID = 42
UPDATE EmployeesSalaryAbove30K
SET Salary += 5000
WHERE DepartmentID = 1
SELECT
DepartmentID,
AVG(Salary) AS [AverageSalary]
FROM EmployeesSalaryAbove30K
GROUP BY DepartmentID
SELECT
DepartmentID,
MAX(Salary) AS [MaxSalary]
FROM Employees
GROUP BY DepartmentID
HAVING MAX(Salary) < 30000 OR MAX(Salary) > 70000
SELECT COUNT(*) AS [Count]
FROM Employees
WHERE ManagerID IS NULL
SELECT DISTINCT DepartmentID, Salary FROM
(
SELECT
DepartmentID,
Salary,
DENSE_RANK() OVER (PARTITION BY DepartmentID ORDER BY Salary DESC) AS [SalaryRank]
FROM Employees
) AS DepartmentsSalariesRanked
WHERE SalaryRank = 3
SELECT TOP(10) FirstName, LastName, DepartmentID
FROM Employees AS e1
WHERE Salary >
(
SELECT AVG(Salary)
FROM Employees AS e2
WHERE e2.DepartmentID = e1.DepartmentID
GROUP BY DepartmentID
)
ORDER BY DepartmentID
|
ALTER TABLE email add column subject text;
|
-- phpMyAdmin SQL Dump
-- version 4.8.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Dec 13, 2018 at 02:29 PM
-- Server version: 10.1.34-MariaDB
-- PHP Version: 7.0.31
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `resina_chemicals`
--
-- --------------------------------------------------------
--
-- Table structure for table `bill_items`
--
CREATE TABLE `bill_items` (
`item_id` int(11) NOT NULL,
`item_product_id` int(11) NOT NULL COMMENT 'Product ID',
`bill_id` int(11) NOT NULL,
`item_name` varchar(100) NOT NULL,
`hsn_code` varchar(30) NOT NULL,
`item_quantity_unit` varchar(50) NOT NULL COMMENT 'this is combination of quantity and unit of product',
`item_rate` varchar(50) NOT NULL,
`bill_quantity` varchar(50) NOT NULL,
`bill_rate` varchar(50) NOT NULL,
`bill_unit` varchar(20) NOT NULL,
`added_by` int(11) NOT NULL,
`added_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`deleted` int(1) NOT NULL DEFAULT '0' COMMENT '0=active, 1= deleted'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `bill_master`
--
CREATE TABLE `bill_master` (
`bill_id` int(11) NOT NULL,
`bill_no` varchar(50) NOT NULL,
`bill_date` date NOT NULL,
`tax_rate` varchar(50) NOT NULL COMMENT 'bill_igst',
`bill_cgst` varchar(50) NOT NULL,
`bill_sgst` varchar(50) NOT NULL,
`bill_igst` varchar(50) NOT NULL,
`bill_subTotal` varchar(50) NOT NULL,
`bill_total` varchar(50) NOT NULL,
`customer_id` int(11) NOT NULL,
`forwardTo_customer_id` int(11) NOT NULL,
`challan_no` varchar(50) NOT NULL,
`challan_date` date DEFAULT NULL,
`dm_no` varchar(50) NOT NULL,
`dm_date` date DEFAULT NULL,
`lr_or_mr_no` varchar(50) NOT NULL,
`lr_or_mr_date` date DEFAULT NULL,
`added_by` int(11) NOT NULL,
`added_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`deleted` int(1) NOT NULL DEFAULT '0' COMMENT '0=active, 1= deleted'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `company_details`
--
CREATE TABLE `company_details` (
`company_id` int(11) NOT NULL,
`company_name` varchar(100) NOT NULL,
`address` varchar(200) NOT NULL,
`city` varchar(20) NOT NULL,
`state` varchar(20) NOT NULL,
`state_code` varchar(5) NOT NULL,
`email` varchar(50) NOT NULL,
`email_password` varchar(255) NOT NULL,
`mobile` varchar(15) NOT NULL,
`alt_mobile` varchar(15) NOT NULL,
`location_lat` varchar(30) NOT NULL,
`location_lang` varchar(30) NOT NULL,
`aaded_by` int(11) NOT NULL,
`added_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`deleted` int(11) NOT NULL DEFAULT '0' COMMENT '0=active, 1=deleted'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `customers`
--
CREATE TABLE `customers` (
`customer_id` int(11) NOT NULL,
`first_name` varchar(50) NOT NULL,
`last_name` varchar(50) NOT NULL,
`gendar` varchar(20) NOT NULL,
`address` varchar(255) NOT NULL,
`city` varchar(50) NOT NULL,
`state` varchar(30) NOT NULL,
`pin` varchar(12) NOT NULL,
`state_code` int(50) NOT NULL COMMENT 'used for billing',
`gst_in_number` varchar(100) NOT NULL,
`mobile` varchar(20) NOT NULL,
`alt_mobile` varchar(30) NOT NULL,
`email` varchar(50) NOT NULL,
`added_by` int(1) NOT NULL,
`added_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`deleted` int(1) NOT NULL DEFAULT '0' COMMENT '0=active, 1=deleted'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `products`
--
CREATE TABLE `products` (
`product_id` int(11) NOT NULL,
`product_name` varchar(255) NOT NULL,
`product_img_name` varchar(255) NOT NULL,
`added_by` int(11) NOT NULL,
`added_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`deleted` int(1) NOT NULL DEFAULT '0' COMMENT '0=active, 1= deleted'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `product_attributes`
--
CREATE TABLE `product_attributes` (
`attribute_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`quantity` double NOT NULL,
`hsn_code` varchar(100) NOT NULL,
`unit` varchar(20) NOT NULL,
`rate` varchar(20) NOT NULL,
`is_offer_avilable` int(1) NOT NULL DEFAULT '0' COMMENT '0=no offer, 1=offer valued',
`offer_rate` varchar(50) NOT NULL COMMENT 'if offer value = 1 then this rate will be applied',
`effective_from_date` date DEFAULT NULL,
`effective_till_date` date DEFAULT NULL,
`added_by` int(11) NOT NULL,
`added_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`deleted` int(1) NOT NULL DEFAULT '0' COMMENT '0=active, 1=deleted'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `product_stock`
--
CREATE TABLE `product_stock` (
`stock_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`stock_qty` varchar(11) NOT NULL,
`added_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`added_by` int(11) NOT NULL,
`deleted` int(1) NOT NULL DEFAULT '0' COMMENT '0=active, 1=deleted'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`fname` varchar(50) NOT NULL,
`lname` varchar(50) NOT NULL,
`user_type` int(11) NOT NULL COMMENT '1=admin, 2=normalUser',
`username` varchar(50) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`password` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`email` varchar(50) NOT NULL,
`mobile` varchar(20) NOT NULL,
`added_by` int(11) NOT NULL,
`added_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`deleted` int(11) NOT NULL COMMENT '0=active, 1=deleted'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `fname`, `lname`, `user_type`, `username`, `password`, `email`, `mobile`, `added_by`, `added_on`, `deleted`) VALUES
(1, 'Vivek', '<PASSWORD>', 1, '<PASSWORD>je', '<PASSWORD>9a<PASSWORD>9574e1de24ce64485df66db447736e588da9568cb335d8281b972674011f78d714aRlvjIDxfCeS3d4e8dpSORIKlwt9jqQPpMloyCLRrn4=', '<EMAIL>', '9595926091', 1, '2018-12-12 16:41:41', 0),
(2, 'Tushar', 'Kohale', 2, 'Tushar.kohale', '<PASSWORD>aa8c35ba6<PASSWORD>2fef623<PASSWORD>bcb<PASSWORD>a<PASSWORD>Su6U3VDv0v1vyY+zk+oZrY9pJwZgoPP21WxW0bg=', '<EMAIL>', '9898786767', 0, '2018-12-12 16:41:41', 1),
(3, 'Naresh', 'Talathi', 0, 'Naresh', 'df51f7a3f442215066e905149d20b62ec0f11b6961788adebc619063c02388b3ed174e61d7a731b514ad9b646aaef3fc11895f859f29eafc4697b984bde626a2Ogdoq0n1RxKFajARmzVRJAoE6QvRQHJy6mIx+1WboVQ=', '<EMAIL>', '9595959933', 1, '2018-12-12 16:43:12', 0),
(4, 'Naresh', 'Talathi', 0, 'Naresh', 'a57193b65e7cfb5eb99cdeda09180173a21527fb716c0316f19571c38e5cc33dc1edac958d3578065065a1e1d6f196f327c3481912b196c1db8ab61a52415438xWLi5V6togfjxuknhVHhlo29xKOTVDLX69k7xpAe+1E=', '<EMAIL>', '9595959933', 1, '2018-12-12 16:43:46', 1),
(5, 'Jageshwar', 'Gaydhane', 1, 'Jagya', 'cf0995576a654c3ea331c9fac039940ab6cbfb9f574f5ac82f49e47cb10e0b5e77e1ccf1534b8085d0437472c4c2fc24365ac93c2250b3294a20a59d3e13ef02P4MtRKz6NH33s78zsSpUOlN0QICFJhqZjWbc5KUrLos=', '<EMAIL>', '98979879', 1, '2018-12-12 16:48:04', 1),
(6, 'Jogendar', 'ZadopSha', 1, 'Jogendar', '9e96caf1cae442e5c305b331d9c91ef4f5748256452c4c3b4afb219cc3ed52ea17ae4cc9c05b085ae9233e3879243349799ff02ec4cb5c7be181b2f24c834afdRlp1euxaXVsSjUEUynnt0UL1XvEeoIt4TdWFRlffHkc=', '<EMAIL>', '9595959993', 5, '2018-12-12 17:02:39', 1);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `bill_items`
--
ALTER TABLE `bill_items`
ADD PRIMARY KEY (`item_id`),
ADD UNIQUE KEY `item_id` (`item_id`),
ADD KEY `item_id_2` (`item_id`,`bill_id`,`added_by`),
ADD KEY `item_product_id` (`item_product_id`);
--
-- Indexes for table `bill_master`
--
ALTER TABLE `bill_master`
ADD PRIMARY KEY (`bill_id`),
ADD UNIQUE KEY `bill_id` (`bill_id`);
--
-- Indexes for table `company_details`
--
ALTER TABLE `company_details`
ADD PRIMARY KEY (`company_id`);
--
-- Indexes for table `customers`
--
ALTER TABLE `customers`
ADD PRIMARY KEY (`customer_id`),
ADD KEY `customer_id` (`customer_id`),
ADD KEY `customer_id_2` (`customer_id`),
ADD KEY `state_code` (`state_code`);
--
-- Indexes for table `products`
--
ALTER TABLE `products`
ADD PRIMARY KEY (`product_id`),
ADD UNIQUE KEY `product_id` (`product_id`),
ADD KEY `product_id_2` (`product_id`);
--
-- Indexes for table `product_attributes`
--
ALTER TABLE `product_attributes`
ADD PRIMARY KEY (`attribute_id`),
ADD UNIQUE KEY `attribute_id` (`attribute_id`),
ADD KEY `attribute_id_2` (`attribute_id`),
ADD KEY `product_id` (`product_id`);
--
-- Indexes for table `product_stock`
--
ALTER TABLE `product_stock`
ADD PRIMARY KEY (`stock_id`),
ADD UNIQUE KEY `stock_id` (`stock_id`),
ADD KEY `stock_id_2` (`stock_id`),
ADD KEY `product_id` (`product_id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `bill_items`
--
ALTER TABLE `bill_items`
MODIFY `item_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `bill_master`
--
ALTER TABLE `bill_master`
MODIFY `bill_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `company_details`
--
ALTER TABLE `company_details`
MODIFY `company_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `customers`
--
ALTER TABLE `customers`
MODIFY `customer_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
MODIFY `product_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `product_attributes`
--
ALTER TABLE `product_attributes`
MODIFY `attribute_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `product_stock`
--
ALTER TABLE `product_stock`
MODIFY `stock_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
<gh_stars>1-10
-- MySQL dump 10.13 Distrib 5.5.38, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: instaulsk
-- ------------------------------------------------------
-- Server version 5.5.38-0+wheezy1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!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 */;
--
-- Table structure for table `photos`
--
DROP TABLE IF EXISTS `photos`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `photos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created_time` int(11) NOT NULL,
`link` varchar(200) NOT NULL,
`user_id` bigint(20) NOT NULL,
`tag` varchar(200) NOT NULL,
`updated` date NOT NULL,
`next_max_id` varchar(200) NOT NULL,
`photo_id` varchar(50) NOT NULL,
`likes` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `user`
--
DROP TABLE IF EXISTS `user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`user_name` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`banned` tinyint(1) NOT NULL,
`followers` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `user_log`
--
DROP TABLE IF EXISTS `user_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`posts` int(11) NOT NULL,
`followers` int(11) NOT NULL,
`follows` int(11) NOT NULL,
`date` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2015-10-01 1:40:35
|
<reponame>shaneHowearth/nine<gh_stars>1-10
CREATE USER articlewriter;
CREATE DATABASE article_postgres_db owner articlewriter;
GRANT ALL PRIVILEGES ON DATABASE article_postgres_db TO articlewriter;
\connect article_postgres_db articlewriter
CREATE TABLE IF NOT EXISTS article
(
id SERIAL PRIMARY KEY,
title TEXT,
pub_date DATE,
body TEXT,
tags TEXT[]
);
ALTER USER articlewriter WITH PASSWORD '<PASSWORD>';
|
# phpMyAdmin MySQL-Dump
# http://phpwizard.net/phpMyAdmin/
#
# Host: localhost Database : hymod_bddb
# (C) Copyright 2001
# <NAME> <<EMAIL>>
# CSIRO Manufacturing and Infrastructure Technology, Preston Lab
# --------------------------------------------------------
#
# Table structure for table 'boards'
#
DROP TABLE IF EXISTS boards;
CREATE TABLE boards (
serno int(10) unsigned zerofill NOT NULL auto_increment,
ethaddr char(17),
date date NOT NULL,
batch char(32),
type enum('IO','CLP','DSP','INPUT','ALT-INPUT','DISPLAY') NOT NULL,
rev tinyint(3) unsigned zerofill NOT NULL,
location char(64),
comments text,
sdram0 enum('32M','64M','128M','256M','512M','1G','2G','4G'),
sdram1 enum('32M','64M','128M','256M','512M','1G','2G','4G'),
sdram2 enum('32M','64M','128M','256M','512M','1G','2G','4G'),
sdram3 enum('32M','64M','128M','256M','512M','1G','2G','4G'),
flash0 enum('4M','8M','16M','32M','64M','128M','256M','512M','1G'),
flash1 enum('4M','8M','16M','32M','64M','128M','256M','512M','1G'),
flash2 enum('4M','8M','16M','32M','64M','128M','256M','512M','1G'),
flash3 enum('4M','8M','16M','32M','64M','128M','256M','512M','1G'),
zbt0 enum('512K','1M','2M','4M','8M','16M'),
zbt1 enum('512K','1M','2M','4M','8M','16M'),
zbt2 enum('512K','1M','2M','4M','8M','16M'),
zbt3 enum('512K','1M','2M','4M','8M','16M'),
zbt4 enum('512K','1M','2M','4M','8M','16M'),
zbt5 enum('512K','1M','2M','4M','8M','16M'),
zbt6 enum('512K','1M','2M','4M','8M','16M'),
zbt7 enum('512K','1M','2M','4M','8M','16M'),
zbt8 enum('512K','1M','2M','4M','8M','16M'),
zbt9 enum('512K','1M','2M','4M','8M','16M'),
zbta enum('512K','1M','2M','4M','8M','16M'),
zbtb enum('512K','1M','2M','4M','8M','16M'),
zbtc enum('512K','1M','2M','4M','8M','16M'),
zbtd enum('512K','1M','2M','4M','8M','16M'),
zbte enum('512K','1M','2M','4M','8M','16M'),
zbtf enum('512K','1M','2M','4M','8M','16M'),
xlxtyp0 enum('XCV300E','XCV400E','XCV600E','XC2V2000','XC2V3000','XC2V4000','XC2V6000','XC2VP2','XC2VP4','XC2VP7','XC2VP20','XC2VP30','XC2VP50','XC4VFX20','XC4VFX40','XC4VFX60','XC4VFX100','XC4VFX140'),
xlxtyp1 enum('XCV300E','XCV400E','XCV600E','XC2V2000','XC2V3000','XC2V4000','XC2V6000','XC2VP2','XC2VP4','XC2VP7','XC2VP20','XC2VP30','XC2VP50','XC4VFX20','XC4VFX40','XC4VFX60','XC4VFX100','XC4VFX140'),
xlxtyp2 enum('XCV300E','XCV400E','XCV600E','XC2V2000','XC2V3000','XC2V4000','XC2V6000','XC2VP2','XC2VP4','XC2VP7','XC2VP20','XC2VP30','XC2VP50','XC4VFX20','XC4VFX40','XC4VFX60','XC4VFX100','XC4VFX140'),
xlxtyp3 enum('XCV300E','XCV400E','XCV600E','XC2V2000','XC2V3000','XC2V4000','XC2V6000','XC2VP2','XC2VP4','XC2VP7','XC2VP20','XC2VP30','XC2VP50','XC4VFX20','XC4VFX40','XC4VFX60','XC4VFX100','XC4VFX140'),
xlxspd0 enum('6','7','8','4','5','9','10','11','12'),
xlxspd1 enum('6','7','8','4','5','9','10','11','12'),
xlxspd2 enum('6','7','8','4','5','9','10','11','12'),
xlxspd3 enum('6','7','8','4','5','9','10','11','12'),
xlxtmp0 enum('COM','IND'),
xlxtmp1 enum('COM','IND'),
xlxtmp2 enum('COM','IND'),
xlxtmp3 enum('COM','IND'),
xlxgrd0 enum('NORMAL','ENGSAMP'),
xlxgrd1 enum('NORMAL','ENGSAMP'),
xlxgrd2 enum('NORMAL','ENGSAMP'),
xlxgrd3 enum('NORMAL','ENGSAMP'),
cputyp enum('MPC8260(HIP3)','MPC8260A(HIP4)','MPC8280(HIP7)','MPC8560'),
cpuspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ','233MHZ','266MHZ','300MHZ','333MHZ','366MHZ','400MHZ','433MHZ','466MHZ','500MHZ','533MHZ','566MHZ','600MHZ','633MHZ','666MHZ','700MHZ','733MHZ','766MHZ','800MHZ','833MHZ','866MHZ','900MHZ','933MHZ','966MHZ','1000MHZ','1033MHZ','1066MHZ','1100MHZ','1133MHZ','1166MHZ','1200MHZ','1233MHZ','1266MHZ','1300MHZ','1333MHZ'),
cpmspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ','233MHZ','266MHZ','300MHZ','333MHZ','366MHZ','400MHZ','433MHZ','466MHZ','500MHZ','533MHZ','566MHZ','600MHZ','633MHZ','666MHZ','700MHZ','733MHZ','766MHZ','800MHZ','833MHZ','866MHZ','900MHZ','933MHZ','966MHZ','1000MHZ','1033MHZ','1066MHZ','1100MHZ','1133MHZ','1166MHZ','1200MHZ','1233MHZ','1266MHZ','1300MHZ','1333MHZ'),
busspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ','233MHZ','266MHZ','300MHZ','333MHZ','366MHZ','400MHZ','433MHZ','466MHZ','500MHZ','533MHZ','566MHZ','600MHZ','633MHZ','666MHZ','700MHZ','733MHZ','766MHZ','800MHZ','833MHZ','866MHZ','900MHZ','933MHZ','966MHZ','1000MHZ','1033MHZ','1066MHZ','1100MHZ','1133MHZ','1166MHZ','1200MHZ','1233MHZ','1266MHZ','1300MHZ','1333MHZ'),
hstype enum('AMCC-S2064A','Xilinx-Rockets'),
hschin enum('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16'),
hschout enum('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16'),
PRIMARY KEY (serno),
KEY serno (serno),
UNIQUE serno_2 (serno)
);
#
# Table structure for table 'log'
#
DROP TABLE IF EXISTS log;
CREATE TABLE log (
logno int(10) unsigned zerofill NOT NULL auto_increment,
serno int(10) unsigned zerofill NOT NULL,
date date NOT NULL,
details text NOT NULL,
PRIMARY KEY (logno),
KEY logno (logno, serno, date),
UNIQUE logno_2 (logno)
);
|
<reponame>ministryofjustice/visit-scheduler<filename>src/main/resources/db/migration/V1_2__create_visit_contact_table.sql<gh_stars>1-10
CREATE TABLE visit_contact
(
id serial NOT NULL PRIMARY KEY,
visit_id integer NOT NULL UNIQUE,
contact_name VARCHAR(80) NOT NULL,
contact_phone VARCHAR(40) NOT NULL
); |
-- file:alter_table.sql ln:1590 expect:true
create schema alter2
|
-- file:foreign_key.sql ln:577 expect:true
insert into pktable (base1, ptest1, base2, ptest2) values (1, 3, 2, 2)
|
<reponame>one-touch-pipeline/otp<gh_stars>0
ALTER TABLE project DROP COLUMN snv;
|
/**
THIS IS AHJO SQL SCRIPT TEMPLATE
================================
USE THIS TEMPLATE AS AN EXAMPLE
WHEN CREATING YOUR OWN SCRIPTS.
NAMING CONVENTION:
<schema>.<object name>.sql
*/
-- First, truncate table
/**
TRUNCATE TABLE schema.tableNAme
-- Second, perform data insert
INSERT INTO schema.tableNAme (col1, col2) VALUES (1, 'test')
*/ |
--NOTES
--This code assumes that table names can only be 63 chars long
CREATE OR REPLACE FUNCTION _prom_catalog.get_default_chunk_interval()
RETURNS INTERVAL
AS $func$
SELECT value::INTERVAL FROM _prom_catalog.default WHERE key='chunk_interval';
$func$
LANGUAGE SQL STABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_default_chunk_interval() TO prom_reader;
CREATE OR REPLACE FUNCTION _prom_catalog.get_timescale_major_version()
RETURNS INT
AS $func$
SELECT split_part(extversion, '.', 1)::INT FROM pg_catalog.pg_extension WHERE extname='timescaledb' LIMIT 1;
$func$
LANGUAGE SQL STABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_timescale_major_version() TO prom_reader;
CREATE OR REPLACE FUNCTION _prom_catalog.get_timescale_minor_version()
RETURNS INT
AS $func$
SELECT split_part(extversion, '.', 2)::INT FROM pg_catalog.pg_extension WHERE extname='timescaledb' LIMIT 1;
$func$
LANGUAGE SQL STABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_timescale_minor_version() TO prom_reader;
CREATE OR REPLACE FUNCTION _prom_catalog.get_default_retention_period()
RETURNS INTERVAL
AS $func$
SELECT value::INTERVAL FROM _prom_catalog.default WHERE key='retention_period';
$func$
LANGUAGE SQL STABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_default_retention_period() TO prom_reader;
CREATE OR REPLACE FUNCTION _prom_catalog.is_timescaledb_installed()
RETURNS BOOLEAN
AS $func$
SELECT count(*) > 0 FROM pg_extension WHERE extname='timescaledb';
$func$
LANGUAGE SQL STABLE;
GRANT EXECUTE ON FUNCTION _prom_catalog.is_timescaledb_installed() TO prom_reader;
CREATE OR REPLACE FUNCTION _prom_catalog.is_timescaledb_oss()
RETURNS BOOLEAN AS
$$
BEGIN
IF _prom_catalog.is_timescaledb_installed() THEN
IF _prom_catalog.get_timescale_major_version() >= 2 THEN
-- TimescaleDB 2.x
RETURN (SELECT current_setting('timescaledb.license') = 'apache');
ELSE
-- TimescaleDB 1.x
-- Note: We cannot use current_setting() in 1.x, otherwise we get permission errors as
-- we need to be superuser. We should not enforce the use of superuser. Hence, we take
-- help of a view.
RETURN (SELECT edition = 'apache' FROM timescaledb_information.license);
END IF;
END IF;
RETURN false;
END;
$$
LANGUAGE plpgsql;
GRANT EXECUTE ON FUNCTION _prom_catalog.is_timescaledb_oss() TO prom_reader;
CREATE OR REPLACE FUNCTION _prom_catalog.is_multinode()
RETURNS BOOLEAN
AS $func$
DECLARE
is_distributed BOOLEAN = false;
BEGIN
IF _prom_catalog.get_timescale_major_version() >= 2 THEN
SELECT count(*) > 0 FROM timescaledb_information.data_nodes
INTO is_distributed;
END IF;
RETURN is_distributed;
EXCEPTION WHEN SQLSTATE '42P01' THEN -- Timescale 1.x, never distributed
RETURN false;
END
$func$
LANGUAGE PLPGSQL STABLE;
GRANT EXECUTE ON FUNCTION _prom_catalog.is_multinode() TO prom_reader;
CREATE OR REPLACE FUNCTION _prom_catalog.get_default_compression_setting()
RETURNS BOOLEAN
AS $func$
SELECT value::BOOLEAN FROM _prom_catalog.default WHERE key='metric_compression';
$func$
LANGUAGE SQL STABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_default_compression_setting() TO prom_reader;
--Add 1% of randomness to the interval so that chunks are not aligned so that chunks are staggered for compression jobs.
CREATE OR REPLACE FUNCTION _prom_catalog.get_staggered_chunk_interval(chunk_interval INTERVAL)
RETURNS INTERVAL
AS $func$
SELECT chunk_interval * (1.0+((random()*0.01)-0.005));
$func$
LANGUAGE SQL VOLATILE;
--only used for setting chunk interval, and admin function
GRANT EXECUTE ON FUNCTION _prom_catalog.get_staggered_chunk_interval(INTERVAL) TO prom_admin;
CREATE OR REPLACE FUNCTION _prom_catalog.get_advisory_lock_prefix_job()
RETURNS INTEGER
AS $func$
SELECT 12377;
$func$
LANGUAGE SQL IMMUTABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_advisory_lock_prefix_job() TO prom_writer;
CREATE OR REPLACE FUNCTION _prom_catalog.get_advisory_lock_prefix_maintenance()
RETURNS INTEGER
AS $func$
SELECT 12378;
$func$
LANGUAGE SQL IMMUTABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_advisory_lock_prefix_maintenance() TO prom_maintenance;
CREATE OR REPLACE FUNCTION _prom_catalog.lock_metric_for_maintenance(metric_id int, wait boolean = true)
RETURNS BOOLEAN
AS $func$
DECLARE
res BOOLEAN;
BEGIN
IF NOT wait THEN
SELECT pg_try_advisory_lock(_prom_catalog.get_advisory_lock_prefix_maintenance(), metric_id) INTO STRICT res;
RETURN res;
ELSE
PERFORM pg_advisory_lock(_prom_catalog.get_advisory_lock_prefix_maintenance(), metric_id);
RETURN TRUE;
END IF;
END
$func$
LANGUAGE PLPGSQL VOLATILE;
GRANT EXECUTE ON FUNCTION _prom_catalog.lock_metric_for_maintenance(int, boolean) TO prom_maintenance;
CREATE OR REPLACE FUNCTION _prom_catalog.unlock_metric_for_maintenance(metric_id int)
RETURNS VOID
AS $func$
DECLARE
BEGIN
PERFORM pg_advisory_unlock(_prom_catalog.get_advisory_lock_prefix_maintenance(), metric_id);
END
$func$
LANGUAGE PLPGSQL VOLATILE;
GRANT EXECUTE ON FUNCTION _prom_catalog.unlock_metric_for_maintenance(int) TO prom_maintenance;
CREATE OR REPLACE FUNCTION _prom_catalog.attach_series_partition(metric_record _prom_catalog.metric) RETURNS VOID
AS $proc$
DECLARE
BEGIN
EXECUTE format($$
ALTER TABLE _prom_catalog.series ATTACH PARTITION prom_data_series.%1$I FOR VALUES IN (%2$L)
$$, metric_record.table_name, metric_record.id);
END;
$proc$
LANGUAGE PLPGSQL
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION _prom_catalog.attach_series_partition(_prom_catalog.metric) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.attach_series_partition(_prom_catalog.metric) TO prom_writer;
--Canonical lock ordering:
--metrics
--data table
--labels
--series parent
--series partition
--constraints:
--- The prom_metric view takes locks in the order: data table, series partition.
--This procedure finalizes the creation of a metric. The first part of
--metric creation happens in make_metric_table and the final part happens here.
--We split metric creation into two parts to minimize latency during insertion
--(which happens in the make_metric_table path). Especially noteworthy is that
--attaching the partition to the series table happens here because it requires
--an exclusive lock, which is a high-latency operation. The other actions this
--function does are not as critical latency-wise but are also not necessary
--to perform in order to insert data and thus are put here.
--
--Note: that a consequence of this design is that the series partition is attached
--to the series parent after in this step. Thus a metric might not be seen in some
--cross-metric queries right away. Those queries aren't common however and the delay
--is insignificant in practice.
--
--lock-order: metric table, data_table, series parent, series partition
CREATE OR REPLACE PROCEDURE _prom_catalog.finalize_metric_creation()
AS $proc$
DECLARE
r _prom_catalog.metric;
created boolean;
is_view boolean;
BEGIN
FOR r IN
SELECT *
FROM _prom_catalog.metric
WHERE NOT creation_completed
ORDER BY random()
LOOP
SELECT m.creation_completed, m.is_view
INTO created, is_view
FROM _prom_catalog.metric m
WHERE m.id = r.id
FOR UPDATE;
IF created THEN
--release row lock
COMMIT;
CONTINUE;
END IF;
--do this before taking exclusive lock to minimize work after taking lock
UPDATE _prom_catalog.metric SET creation_completed = TRUE WHERE id = r.id;
-- in case of a view, no need to attach the partition
IF is_view THEN
--release row lock
COMMIT;
CONTINUE;
END IF;
--we will need this lock for attaching the partition so take it now
--This may not be strictly necessary but good
--to enforce lock ordering (parent->child) explicitly. Note:
--creating a table as a partition takes a stronger lock (access exclusive)
--so, attaching a partition is better
LOCK TABLE ONLY _prom_catalog.series IN SHARE UPDATE EXCLUSIVE mode;
PERFORM _prom_catalog.attach_series_partition(r);
COMMIT;
END LOOP;
END;
$proc$ LANGUAGE PLPGSQL;
COMMENT ON PROCEDURE _prom_catalog.finalize_metric_creation()
IS 'Finalizes metric creation. This procedure should be run by the connector automatically';
GRANT EXECUTE ON PROCEDURE _prom_catalog.finalize_metric_creation() TO prom_writer;
--This function is called by a trigger when a new metric is created. It
--sets up the metric just enough to insert data into it. Metric creation
--is completed in finalize_metric_creation() above. See the comments
--on that function for the reasoning for this split design.
--
--Note: latency-sensitive function. Should only contain just enough logic
--to support inserts for the metric.
--lock-order: data table, labels, series partition.
CREATE OR REPLACE FUNCTION _prom_catalog.make_metric_table()
RETURNS trigger
AS $func$
DECLARE
label_id INT;
compressed_hypertable_name text;
BEGIN
-- Note: if the inserted metric is a view, nothing to do.
IF NEW.is_view THEN
RETURN NEW;
END IF;
EXECUTE format('CREATE TABLE %I.%I(time TIMESTAMPTZ NOT NULL, value DOUBLE PRECISION NOT NULL, series_id BIGINT NOT NULL) WITH (autovacuum_vacuum_threshold = 50000, autovacuum_analyze_threshold = 50000)',
NEW.table_schema, NEW.table_name);
EXECUTE format('GRANT SELECT ON TABLE %I.%I TO prom_reader', NEW.table_schema, NEW.table_name);
EXECUTE format('GRANT SELECT, INSERT ON TABLE %I.%I TO prom_writer', NEW.table_schema, NEW.table_name);
EXECUTE format('GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE %I.%I TO prom_modifier', NEW.table_schema, NEW.table_name);
EXECUTE format('CREATE UNIQUE INDEX data_series_id_time_%s ON %I.%I (series_id, time) INCLUDE (value)',
NEW.id, NEW.table_schema, NEW.table_name);
IF _prom_catalog.is_timescaledb_installed() THEN
IF _prom_catalog.is_multinode() THEN
--Note: we intentionally do not partition by series_id here. The assumption is
--that we'll have more "heavy metrics" than nodes and thus partitioning /individual/
--metrics won't gain us much for inserts and would be detrimental for many queries.
PERFORM public.create_distributed_hypertable(
format('%I.%I', NEW.table_schema, NEW.table_name),
'time',
chunk_time_interval=>_prom_catalog.get_staggered_chunk_interval(_prom_catalog.get_default_chunk_interval()),
create_default_indexes=>false
);
ELSE
PERFORM public.create_hypertable(format('%I.%I', NEW.table_schema, NEW.table_name), 'time',
chunk_time_interval=>_prom_catalog.get_staggered_chunk_interval(_prom_catalog.get_default_chunk_interval()),
create_default_indexes=>false);
END IF;
END IF;
--Do not move this into the finalize step, because it's cheap to do while the table is empty
--but takes a heavyweight blocking lock otherwise.
IF _prom_catalog.is_timescaledb_installed()
AND _prom_catalog.get_default_compression_setting() THEN
PERFORM prom_api.set_compression_on_metric_table(NEW.table_name, TRUE);
END IF;
SELECT _prom_catalog.get_or_create_label_id('__name__', NEW.metric_name)
INTO STRICT label_id;
--note that because labels[1] is unique across partitions and UNIQUE(labels) inside partition, labels are guaranteed globally unique
EXECUTE format($$
CREATE TABLE prom_data_series.%1$I (
id bigint NOT NULL,
metric_id int NOT NULL,
labels prom_api.label_array NOT NULL,
delete_epoch BIGINT NULL DEFAULT NULL,
CHECK(labels[1] = %2$L AND labels[1] IS NOT NULL),
CHECK(metric_id = %3$L),
CONSTRAINT series_labels_id_%3$s UNIQUE(labels) INCLUDE (id),
CONSTRAINT series_pkey_%3$s PRIMARY KEY(id)
) WITH (autovacuum_vacuum_threshold = 100, autovacuum_analyze_threshold = 100)
$$, NEW.table_name, label_id, NEW.id);
EXECUTE format('GRANT SELECT ON TABLE prom_data_series.%I TO prom_reader', NEW.table_name);
EXECUTE format('GRANT SELECT, INSERT ON TABLE prom_data_series.%I TO prom_writer', NEW.table_name);
EXECUTE format('GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE prom_data_series.%I TO prom_modifier', NEW.table_name);
RETURN NEW;
END
$func$
LANGUAGE PLPGSQL VOLATILE
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION _prom_catalog.make_metric_table() FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.make_metric_table() TO prom_writer;
DROP TRIGGER IF EXISTS make_metric_table_trigger ON _prom_catalog.metric CASCADE;
CREATE TRIGGER make_metric_table_trigger
AFTER INSERT ON _prom_catalog.metric
FOR EACH ROW
EXECUTE PROCEDURE _prom_catalog.make_metric_table();
------------------------
-- Internal functions --
------------------------
-- Return a table name built from a full_name and a suffix.
-- The full name is truncated so that the suffix could fit in full.
-- name size will always be exactly 62 chars.
CREATE OR REPLACE FUNCTION _prom_catalog.pg_name_with_suffix(
full_name text, suffix text)
RETURNS name
AS $func$
SELECT (substring(full_name for 62-(char_length(suffix)+1)) || '_' || suffix)::name
$func$
LANGUAGE SQL IMMUTABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.pg_name_with_suffix(text, text) TO prom_reader;
-- Return a new unique name from a name and id.
-- This tries to use the full_name in full. But if the
-- full name doesn't fit, generates a new unique name.
-- Note that there cannot be a collision betweeen a user
-- defined name and a name with a suffix because user
-- defined names of length 62 always get a suffix and
-- conversely, all names with a suffix are length 62.
-- We use a max name length of 62 not 63 because table creation creates an
-- array type named `_tablename`. We need to ensure that this name is
-- unique as well, so have to reserve a space for the underscore.
CREATE OR REPLACE FUNCTION _prom_catalog.pg_name_unique(
full_name_arg text, suffix text)
RETURNS name
AS $func$
SELECT CASE
WHEN char_length(full_name_arg) < 62 THEN
full_name_arg::name
ELSE
_prom_catalog.pg_name_with_suffix(
full_name_arg, suffix
)
END
$func$
LANGUAGE SQL IMMUTABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.pg_name_unique(text, text) TO prom_reader;
--Creates a new table for a given metric name.
--This uses up some sequences so should only be called
--If the table does not yet exist.
--The function inserts into the metric catalog table,
-- which causes the make_metric_table trigger to fire,
-- which actually creates the table
-- locks: metric, make_metric_table[data table, labels, series partition]
CREATE OR REPLACE FUNCTION _prom_catalog.create_metric_table(
metric_name_arg text, OUT id int, OUT table_name name)
AS $func$
DECLARE
new_id int;
new_table_name name;
BEGIN
new_id = nextval(pg_get_serial_sequence('_prom_catalog.metric','id'))::int;
new_table_name = _prom_catalog.pg_name_unique(metric_name_arg, new_id::text);
LOOP
INSERT INTO _prom_catalog.metric (id, metric_name, table_schema, table_name, series_table)
SELECT new_id,
metric_name_arg,
'prom_data',
new_table_name,
new_table_name
ON CONFLICT DO NOTHING
RETURNING _prom_catalog.metric.id, _prom_catalog.metric.table_name
INTO id, table_name;
-- under high concurrency the insert may not return anything, so try a select and loop
-- https://stackoverflow.com/a/15950324
EXIT WHEN FOUND;
SELECT m.id, m.table_name
INTO id, table_name
FROM _prom_catalog.metric m
WHERE metric_name = metric_name_arg;
EXIT WHEN FOUND;
END LOOP;
END
$func$
LANGUAGE PLPGSQL VOLATILE ;
GRANT EXECUTE ON FUNCTION _prom_catalog.create_metric_table(text) TO prom_writer;
--Creates a new label_key row for a given key.
--This uses up some sequences so should only be called
--If the table does not yet exist.
CREATE OR REPLACE FUNCTION _prom_catalog.create_label_key(
new_key TEXT, OUT id INT, OUT value_column_name NAME, OUT id_column_name NAME
)
AS $func$
DECLARE
new_id int;
BEGIN
new_id = nextval(pg_get_serial_sequence('_prom_catalog.label_key','id'))::int;
LOOP
INSERT INTO _prom_catalog.label_key (id, key, value_column_name, id_column_name)
SELECT new_id,
new_key,
_prom_catalog.pg_name_unique(new_key, new_id::text),
_prom_catalog.pg_name_unique(new_key || '_id', format('%s_id', new_id))
ON CONFLICT DO NOTHING
RETURNING _prom_catalog.label_key.id, _prom_catalog.label_key.value_column_name, _prom_catalog.label_key.id_column_name
INTO id, value_column_name, id_column_name;
-- under high concurrency the insert may not return anything, so try a select and loop
-- https://stackoverflow.com/a/15950324
EXIT WHEN FOUND;
SELECT lk.id, lk.value_column_name, lk.id_column_name
INTO id, value_column_name, id_column_name
FROM _prom_catalog.label_key lk
WHERE key = new_key;
EXIT WHEN FOUND;
END LOOP;
END
$func$
LANGUAGE PLPGSQL VOLATILE;
GRANT EXECUTE ON FUNCTION _prom_catalog.create_label_key(TEXT) TO prom_writer;
--Get a label key row if one doesn't yet exist.
CREATE OR REPLACE FUNCTION _prom_catalog.get_or_create_label_key(
key TEXT, OUT id INT, OUT value_column_name NAME, OUT id_column_name NAME)
AS $func$
SELECT id, value_column_name, id_column_name
FROM _prom_catalog.label_key lk
WHERE lk.key = get_or_create_label_key.key
UNION ALL
SELECT *
FROM _prom_catalog.create_label_key(get_or_create_label_key.key)
LIMIT 1
$func$
LANGUAGE SQL VOLATILE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_or_create_label_key(TEXT) to prom_writer;
-- Get a new label array position for a label key. For any metric,
-- we want the positions to be as compact as possible.
-- This uses some pretty heavy locks so use sparingly.
-- locks: label_key_position, data table, series partition (in view creation),
CREATE OR REPLACE FUNCTION _prom_catalog.get_new_pos_for_key(
metric_name text, metric_table name, key_name_array text[], is_for_exemplar boolean)
RETURNS int[]
AS $func$
DECLARE
position int;
position_array int[];
position_array_idx int;
count_new int;
key_name text;
next_position int;
max_position int;
position_table_name text;
BEGIN
If is_for_exemplar THEN
position_table_name := 'exemplar_label_key_position';
ELSE
position_table_name := 'label_key_position';
END IF;
--Use double check locking here
--fist optimistic check:
position_array := NULL;
EXECUTE FORMAT('SELECT array_agg(p.pos ORDER BY k.ord)
FROM
unnest($1) WITH ORDINALITY as k(key, ord)
INNER JOIN
_prom_catalog.%I p ON
(
p.metric_name = $2
AND p.key = k.key
)', position_table_name) USING key_name_array, metric_name
INTO position_array;
-- Return the array if the length is same, as the received key_name_array does not contain any new keys.
IF array_length(key_name_array, 1) = array_length(position_array, 1) THEN
RETURN position_array;
END IF;
-- Lock tables for exclusiveness.
IF NOT is_for_exemplar THEN
--lock as for ALTER TABLE because we are in effect changing the schema here
--also makes sure the next_position below is correct in terms of concurrency
EXECUTE format('LOCK TABLE prom_data_series.%I IN SHARE UPDATE EXCLUSIVE MODE', metric_table);
ELSE
LOCK TABLE _prom_catalog.exemplar_label_key_position IN ACCESS EXCLUSIVE MODE;
END IF;
max_position := NULL;
EXECUTE FORMAT('SELECT max(pos) + 1
FROM _prom_catalog.%I
WHERE metric_name = $1', position_table_name) USING get_new_pos_for_key.metric_name
INTO max_position;
IF max_position IS NULL THEN
IF is_for_exemplar THEN
max_position := 1;
ELSE
-- Specific to label_key_position table only.
max_position := 2; -- element 1 reserved for __name__
END IF;
END IF;
position_array := array[]::int[];
position_array_idx := 1;
count_new := 0;
FOREACH key_name IN ARRAY key_name_array LOOP
--second check after lock
position := NULL;
EXECUTE FORMAT('SELECT pos FROM _prom_catalog.%I lp
WHERE
lp.metric_name = $1
AND
lp.key = $2', position_table_name) USING metric_name, key_name
INTO position;
IF position IS NOT NULL THEN
position_array[position_array_idx] := position;
position_array_idx := position_array_idx + 1;
CONTINUE;
END IF;
-- key_name does not exists in the position table.
count_new := count_new + 1;
IF (NOT is_for_exemplar) AND (key_name = '__name__') THEN
next_position := 1; -- 1-indexed arrays, __name__ as first element
ELSE
next_position := max_position;
max_position := max_position + 1;
END IF;
IF NOT is_for_exemplar THEN
PERFORM _prom_catalog.get_or_create_label_key(key_name);
END IF;
position := NULL;
EXECUTE FORMAT('INSERT INTO _prom_catalog.%I
VALUES ($1, $2, $3)
ON CONFLICT DO NOTHING
RETURNING pos', position_table_name) USING metric_name, key_name, next_position
INTO position;
IF position IS NULL THEN
RAISE 'Could not find a new position. (is_for_exemplar=%)', is_for_exemplar;
END IF;
position_array[position_array_idx] := position;
position_array_idx := position_array_idx + 1;
END LOOP;
IF NOT is_for_exemplar AND count_new > 0 THEN
--note these functions are expensive in practice so they
--must be run once across a collection of keys
PERFORM _prom_catalog.create_series_view(metric_name);
PERFORM _prom_catalog.create_metric_view(metric_name);
END IF;
RETURN position_array;
END
$func$
LANGUAGE PLPGSQL
--security definer needed to lock the series table
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION _prom_catalog.get_new_pos_for_key(text, name, text[], boolean) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_new_pos_for_key(text, name, text[], boolean) TO prom_reader; -- For exemplars querying.
GRANT EXECUTE ON FUNCTION _prom_catalog.get_new_pos_for_key(text, name, text[], boolean) TO prom_writer;
--should only be called after a check that that the label doesn't exist
CREATE OR REPLACE FUNCTION _prom_catalog.get_new_label_id(key_name text, value_name text, OUT id INT)
AS $func$
BEGIN
LOOP
INSERT INTO
_prom_catalog.label(key, value)
VALUES
(key_name,value_name)
ON CONFLICT DO NOTHING
RETURNING _prom_catalog.label.id
INTO id;
EXIT WHEN FOUND;
SELECT
l.id
INTO id
FROM _prom_catalog.label l
WHERE
key = key_name AND
value = value_name;
EXIT WHEN FOUND;
END LOOP;
END
$func$
LANGUAGE PLPGSQL VOLATILE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_new_label_id(text, text) to prom_writer;
--wrapper around jsonb_each_text to give a better row_estimate
--for labels (10 not 100)
CREATE OR REPLACE FUNCTION _prom_catalog.label_jsonb_each_text(js jsonb, OUT key text, OUT value text)
RETURNS SETOF record
LANGUAGE SQL
IMMUTABLE PARALLEL SAFE STRICT ROWS 10
AS $function$ SELECT (jsonb_each_text(js)).* $function$;
GRANT EXECUTE ON FUNCTION _prom_catalog.label_jsonb_each_text(jsonb) to prom_reader;
--wrapper around unnest to give better row estimate (10 not 100)
CREATE OR REPLACE FUNCTION _prom_catalog.label_unnest(label_array anyarray)
RETURNS SETOF anyelement
LANGUAGE SQL
IMMUTABLE PARALLEL SAFE STRICT ROWS 10
AS $function$ SELECT unnest(label_array) $function$;
GRANT EXECUTE ON FUNCTION _prom_catalog.label_unnest(anyarray) to prom_reader;
-- safe_approximate_row_count returns the approximate row count of a hypertable if timescaledb is installed
-- else returns the approximate row count in the normal table. This prevents errors in approximate count calculation
-- if timescaledb is not installed, which is the case in plain postgres support.
CREATE OR REPLACE FUNCTION _prom_catalog.safe_approximate_row_count(table_name_input REGCLASS) RETURNS BIGINT
LANGUAGE PLPGSQL
AS
$$
BEGIN
IF _prom_catalog.get_timescale_major_version() >= 2 THEN
RETURN (SELECT * FROM approximate_row_count(table_name_input));
ELSE
IF _prom_catalog.is_timescaledb_installed()
AND (SELECT count(*) > 0
FROM _timescaledb_catalog.hypertable
WHERE format('%I.%I', schema_name, table_name)::regclass=table_name_input)
THEN
RETURN (SELECT row_estimate FROM hypertable_approximate_row_count(table_name_input));
END IF;
RETURN (SELECT reltuples::BIGINT FROM pg_class WHERE oid=table_name_input);
END IF;
END;
$$;
GRANT EXECUTE ON FUNCTION _prom_catalog.safe_approximate_row_count(regclass) to prom_reader;
CREATE OR REPLACE FUNCTION _prom_catalog.delete_series_catalog_row(
metric_table name,
series_ids bigint[]
) RETURNS VOID AS
$$
BEGIN
EXECUTE FORMAT(
'UPDATE prom_data_series.%1$I SET delete_epoch = current_epoch+1 FROM _prom_catalog.ids_epoch WHERE delete_epoch IS NULL AND id = ANY($1)',
metric_table
) USING series_ids;
RETURN;
END;
$$
LANGUAGE PLPGSQL;
GRANT EXECUTE ON FUNCTION _prom_catalog.delete_series_catalog_row(name, bigint[]) to prom_modifier;
---------------------------------------------------
------------------- Public APIs -------------------
---------------------------------------------------
CREATE OR REPLACE FUNCTION _prom_catalog.get_metric_table_name_if_exists(
schema text, metric_name text)
RETURNS TABLE (id int, table_name name, table_schema name, series_table name, is_view boolean)
AS $func$
DECLARE
rows_found bigint;
BEGIN
IF get_metric_table_name_if_exists.schema != '' AND get_metric_table_name_if_exists.schema IS NOT NULL THEN
RETURN QUERY SELECT m.id, m.table_name::name, m.table_schema::name, m.series_table::name, m.is_view
FROM _prom_catalog.metric m
WHERE m.table_schema = get_metric_table_name_if_exists.schema
AND m.metric_name = get_metric_table_name_if_exists.metric_name;
RETURN;
END IF;
RETURN QUERY SELECT m.id, m.table_name::name, m.table_schema::name, m.series_table::name, m.is_view
FROM _prom_catalog.metric m
WHERE m.table_schema = 'prom_data'
AND m.metric_name = get_metric_table_name_if_exists.metric_name;
IF FOUND THEN
RETURN;
END IF;
SELECT count(*)
INTO rows_found
FROM _prom_catalog.metric m
WHERE m.metric_name = get_metric_table_name_if_exists.metric_name;
IF rows_found <= 1 THEN
RETURN QUERY SELECT m.id, m.table_name::name, m.table_schema::name, m.series_table::name, m.is_view
FROM _prom_catalog.metric m
WHERE m.metric_name = get_metric_table_name_if_exists.metric_name;
RETURN;
END IF;
RAISE EXCEPTION 'found multiple metrics with same name in different schemas, please specify exact schema name';
END
$func$
LANGUAGE PLPGSQL STABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_metric_table_name_if_exists(text, text) to prom_reader;
-- Public function to get the name of the table for a given metric
-- This will create the metric table if it does not yet exist.
CREATE OR REPLACE FUNCTION _prom_catalog.get_or_create_metric_table_name(
metric_name text, OUT id int, OUT table_name name, OUT possibly_new BOOLEAN)
AS $func$
SELECT id, table_name::name, false
FROM _prom_catalog.metric m
WHERE m.metric_name = get_or_create_metric_table_name.metric_name
AND m.table_schema = 'prom_data'
UNION ALL
SELECT *, true
FROM _prom_catalog.create_metric_table(get_or_create_metric_table_name.metric_name)
LIMIT 1
$func$
LANGUAGE SQL VOLATILE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_or_create_metric_table_name(text) to prom_writer;
--public function to get the array position for a label key
CREATE OR REPLACE FUNCTION _prom_catalog.get_or_create_label_key_pos(
metric_name text, key text)
RETURNS INT
AS $$
--only executes the more expensive PLPGSQL function if the label doesn't exist
SELECT
pos
FROM
_prom_catalog.label_key_position lkp
WHERE
lkp.metric_name = get_or_create_label_key_pos.metric_name
AND lkp.key = get_or_create_label_key_pos.key
UNION ALL
SELECT
(_prom_catalog.get_new_pos_for_key(get_or_create_label_key_pos.metric_name, m.table_name, array[get_or_create_label_key_pos.key], false))[1]
FROM
_prom_catalog.get_or_create_metric_table_name(get_or_create_label_key_pos.metric_name) m
LIMIT 1
$$
LANGUAGE SQL VOLATILE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_or_create_label_key_pos(text, text) to prom_writer;
-- label_cardinality returns the cardinality of a label_pair id in the series table.
-- In simple terms, it means the number of times a label_pair/label_matcher is used
-- across all the series.
CREATE OR REPLACE FUNCTION prom_api.label_cardinality(label_id INT)
RETURNS INT
LANGUAGE SQL
AS
$$
SELECT count(*)::INT FROM _prom_catalog.series s WHERE s.labels @> array[label_id];
$$ STABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION prom_api.label_cardinality(int) to prom_reader;
--public function to get the array position for a label key if it exists
--useful in case users want to group by a specific label key
CREATE OR REPLACE FUNCTION prom_api.label_key_position(
metric_name text, key text)
RETURNS INT
AS $$
SELECT
pos
FROM
_prom_catalog.label_key_position lkp
WHERE
lkp.metric_name = label_key_position.metric_name
AND lkp.key = label_key_position.key
LIMIT 1
$$
LANGUAGE SQL STABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION prom_api.label_key_position(text, text) to prom_reader;
-- drop_metric deletes a metric and related series hypertable from the database along with the related series, views and unreferenced labels.
CREATE OR REPLACE FUNCTION prom_api.drop_metric(metric_name_to_be_dropped text) RETURNS VOID
AS
$$
DECLARE
hypertable_name TEXT;
deletable_metric_id INTEGER;
BEGIN
IF (SELECT NOT pg_try_advisory_xact_lock(5585198506344173278)) THEN
RAISE NOTICE 'drop_metric can run only when no Promscale connectors are running. Please shutdown the Promscale connectors';
PERFORM pg_advisory_xact_lock(5585198506344173278);
END IF;
SELECT table_name, id INTO hypertable_name, deletable_metric_id FROM _prom_catalog.metric WHERE metric_name=metric_name_to_be_dropped;
RAISE NOTICE 'deleting "%" metric with metric_id as "%" and table_name as "%"', metric_name_to_be_dropped, deletable_metric_id, hypertable_name;
EXECUTE FORMAT('DROP VIEW prom_series.%1$I;', hypertable_name);
EXECUTE FORMAT('DROP VIEW prom_metric.%1$I;', hypertable_name);
EXECUTE FORMAT('DROP TABLE prom_data_series.%1$I;', hypertable_name);
EXECUTE FORMAT('DROP TABLE prom_data.%1$I;', hypertable_name);
DELETE FROM _prom_catalog.metric WHERE id=deletable_metric_id;
-- clean up unreferenced labels, label_keys and its position.
DELETE FROM _prom_catalog.label_key_position WHERE metric_name=metric_name_to_be_dropped;
DELETE FROM _prom_catalog.label_key WHERE key NOT IN (select key from _prom_catalog.label_key_position);
END;
$$
LANGUAGE plpgsql;
--Get the label_id for a key, value pair
-- no need for a get function only as users will not be using ids directly
CREATE OR REPLACE FUNCTION _prom_catalog.get_or_create_label_id(
key_name text, value_name text)
RETURNS INT
AS $$
--first select to prevent sequence from being used up
--unnecessarily
SELECT
id
FROM _prom_catalog.label
WHERE
key = key_name AND
value = value_name
UNION ALL
SELECT
_prom_catalog.get_new_label_id(key_name, value_name)
LIMIT 1
$$
LANGUAGE SQL VOLATILE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_or_create_label_id(text, text) to prom_writer;
--This generates a position based array from the jsonb
--0s represent keys that are not set (we don't use NULL
--since intarray does not support it).
--This is not super performance critical since this
--is only used on the insert client and is cached there.
--Read queries can use the eq function or others with the jsonb to find equality
CREATE OR REPLACE FUNCTION _prom_catalog.get_or_create_label_array(js jsonb)
RETURNS prom_api.label_array AS $$
WITH idx_val AS (
SELECT
-- only call the functions to create new key positions
-- and label ids if they don't exist (for performance reasons)
coalesce(lkp.pos,
_prom_catalog.get_or_create_label_key_pos(js->>'__name__', e.key)) idx,
coalesce(l.id,
_prom_catalog.get_or_create_label_id(e.key, e.value)) val
FROM label_jsonb_each_text(js) e
LEFT JOIN _prom_catalog.label l
ON (l.key = e.key AND l.value = e.value)
LEFT JOIN _prom_catalog.label_key_position lkp
ON
(
lkp.metric_name = js->>'__name__' AND
lkp.key = e.key
)
--needs to order by key to prevent deadlocks if get_or_create_label_id is creating labels
ORDER BY l.key
)
SELECT ARRAY(
SELECT coalesce(idx_val.val, 0)
FROM
generate_series(
1,
(SELECT max(idx) FROM idx_val)
) g
LEFT JOIN idx_val ON (idx_val.idx = g)
)::prom_api.label_array
$$
LANGUAGE SQL VOLATILE;
COMMENT ON FUNCTION _prom_catalog.get_or_create_label_array(jsonb)
IS 'converts a jsonb to a label array';
GRANT EXECUTE ON FUNCTION _prom_catalog.get_or_create_label_array(jsonb) TO prom_writer;
CREATE OR REPLACE FUNCTION _prom_catalog.get_or_create_label_array(metric_name TEXT, label_keys text[], label_values text[])
RETURNS prom_api.label_array AS $$
WITH idx_val AS (
SELECT
-- only call the functions to create new key positions
-- and label ids if they don't exist (for performance reasons)
coalesce(lkp.pos,
_prom_catalog.get_or_create_label_key_pos(get_or_create_label_array.metric_name, kv.key)) idx,
coalesce(l.id,
_prom_catalog.get_or_create_label_id(kv.key, kv.value)) val
FROM ROWS FROM(unnest(label_keys), UNNEST(label_values)) AS kv(key, value)
LEFT JOIN _prom_catalog.label l
ON (l.key = kv.key AND l.value = kv.value)
LEFT JOIN _prom_catalog.label_key_position lkp
ON
(
lkp.metric_name = get_or_create_label_array.metric_name AND
lkp.key = kv.key
)
ORDER BY kv.key
)
SELECT ARRAY(
SELECT coalesce(idx_val.val, 0)
FROM
generate_series(
1,
(SELECT max(idx) FROM idx_val)
) g
LEFT JOIN idx_val ON (idx_val.idx = g)
)::prom_api.label_array
$$
LANGUAGE SQL VOLATILE;
COMMENT ON FUNCTION _prom_catalog.get_or_create_label_array(text, text[], text[])
IS 'converts a metric name, array of keys, and array of values to a label array';
GRANT EXECUTE ON FUNCTION _prom_catalog.get_or_create_label_array(TEXT, text[], text[]) TO prom_writer;
CREATE OR REPLACE FUNCTION _prom_catalog.get_or_create_label_ids(metric_name TEXT, metric_table NAME, label_keys text[], label_values text[])
RETURNS TABLE(pos int[], id int[], label_key text[], label_value text[]) AS $$
WITH cte as (
SELECT
-- only call the functions to create new key positions
-- and label ids if they don't exist (for performance reasons)
lkp.pos as known_pos,
coalesce(l.id, _prom_catalog.get_or_create_label_id(kv.key, kv.value)) label_id,
kv.key key_str,
kv.value val_str
FROM ROWS FROM(unnest(label_keys), UNNEST(label_values)) AS kv(key, value)
LEFT JOIN _prom_catalog.label l
ON (l.key = kv.key AND l.value = kv.value)
LEFT JOIN _prom_catalog.label_key_position lkp ON
(
lkp.metric_name = get_or_create_label_ids.metric_name AND
lkp.key = kv.key
)
ORDER BY kv.key, kv.value
)
SELECT
case when count(*) = count(known_pos) Then
array_agg(known_pos)
else
_prom_catalog.get_new_pos_for_key(get_or_create_label_ids.metric_name, get_or_create_label_ids.metric_table, array_agg(key_str), false)
end as poss,
array_agg(label_id) as label_ids,
array_agg(key_str) as keys,
array_agg(val_str) as vals
FROM cte
$$
LANGUAGE SQL VOLATILE;
COMMENT ON FUNCTION _prom_catalog.get_or_create_label_ids(text, name, text[], text[])
IS 'converts a metric name, array of keys, and array of values to a list of label ids';
GRANT EXECUTE ON FUNCTION _prom_catalog.get_or_create_label_ids(TEXT, NAME, text[], text[]) TO prom_writer;
-- Returns ids, keys and values for a label_array
-- the order may not be the same as the original labels
-- This function needs to be optimized for performance
CREATE OR REPLACE FUNCTION prom_api.labels_info(INOUT labels INT[], OUT keys text[], OUT vals text[])
AS $$
SELECT
array_agg(l.id), array_agg(l.key), array_agg(l.value)
FROM
_prom_catalog.label_unnest(labels) label_id
INNER JOIN _prom_catalog.label l ON (l.id = label_id)
$$
LANGUAGE SQL STABLE PARALLEL SAFE;
COMMENT ON FUNCTION prom_api.labels_info(INT[])
IS 'converts an array of label ids to three arrays: one for ids, one for keys and another for values';
GRANT EXECUTE ON FUNCTION prom_api.labels_info(INT[]) TO prom_reader;
CREATE OR REPLACE FUNCTION prom_api.key_value_array(labels prom_api.label_array, OUT keys text[], OUT vals text[])
AS $$
SELECT keys, vals FROM prom_api.labels_info(labels)
$$
LANGUAGE SQL STABLE PARALLEL SAFE;
COMMENT ON FUNCTION prom_api.key_value_array(prom_api.label_array)
IS 'converts a labels array to two arrays: one for keys and another for values';
GRANT EXECUTE ON FUNCTION prom_api.key_value_array(prom_api.label_array) TO prom_reader;
--Returns the jsonb for a series defined by a label_array
CREATE OR REPLACE FUNCTION prom_api.jsonb(labels prom_api.label_array)
RETURNS jsonb AS $$
SELECT
jsonb_object(keys, vals)
FROM
prom_api.key_value_array(labels)
$$
LANGUAGE SQL STABLE PARALLEL SAFE;
COMMENT ON FUNCTION prom_api.jsonb(labels prom_api.label_array)
IS 'converts a labels array to a JSONB object';
GRANT EXECUTE ON FUNCTION prom_api.jsonb(prom_api.label_array) TO prom_reader;
--Returns the label_array given a series_id
CREATE OR REPLACE FUNCTION prom_api.labels(series_id BIGINT)
RETURNS prom_api.label_array AS $$
SELECT
labels
FROM
_prom_catalog.series
WHERE id = series_id
$$
LANGUAGE SQL STABLE PARALLEL SAFE;
COMMENT ON FUNCTION prom_api.labels(series_id BIGINT)
IS 'fetches labels array for the given series id';
GRANT EXECUTE ON FUNCTION prom_api.labels(series_id BIGINT) TO prom_reader;
--Do not call before checking that the series does not yet exist
CREATE OR REPLACE FUNCTION _prom_catalog.create_series(
metric_id int,
metric_table_name NAME,
label_array prom_api.label_array,
OUT series_id BIGINT)
AS $func$
DECLARE
new_series_id bigint;
BEGIN
new_series_id = nextval('_prom_catalog.series_id');
LOOP
EXECUTE format ($$
INSERT INTO prom_data_series.%I(id, metric_id, labels)
SELECT $1, $2, $3
ON CONFLICT DO NOTHING
RETURNING id
$$, metric_table_name)
INTO series_id
USING new_series_id, metric_id, label_array;
EXIT WHEN series_id is not null;
EXECUTE format($$
SELECT id
FROM prom_data_series.%I
WHERE labels = $1
$$, metric_table_name)
INTO series_id
USING label_array;
EXIT WHEN series_id is not null;
END LOOP;
END
$func$
LANGUAGE PLPGSQL VOLATILE;
GRANT EXECUTE ON FUNCTION _prom_catalog.create_series(int, name, prom_api.label_array) TO prom_writer;
CREATE OR REPLACE FUNCTION _prom_catalog.resurrect_series_ids(metric_table name, series_id bigint)
RETURNS VOID
AS $func$
BEGIN
EXECUTE FORMAT($query$
UPDATE prom_data_series.%1$I
SET delete_epoch = NULL
WHERE id = $1
$query$, metric_table) using series_id;
END
$func$
LANGUAGE PLPGSQL VOLATILE
--security definer to add jobs as the logged-in user
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION _prom_catalog.resurrect_series_ids(name, bigint) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.resurrect_series_ids(name, bigint) TO prom_writer;
-- There shouldn't be a need to have a read only version of this as we'll use
-- the eq or other matcher functions to find series ids like this. However,
-- there are possible use cases that need the series id directly for performance
-- that we might want to see if we need to support, in which case a
-- read only version might be useful in future.
CREATE OR REPLACE FUNCTION _prom_catalog.get_or_create_series_id(label jsonb)
RETURNS BIGINT AS $$
DECLARE
series_id bigint;
table_name name;
metric_id int;
BEGIN
--See get_or_create_series_id_for_kv_array for notes about locking
SELECT mtn.id, mtn.table_name FROM _prom_catalog.get_or_create_metric_table_name(label->>'__name__') mtn
INTO metric_id, table_name;
LOCK TABLE ONLY _prom_catalog.series in ACCESS SHARE mode;
EXECUTE format($query$
WITH cte AS (
SELECT _prom_catalog.get_or_create_label_array($1)
), existing AS (
SELECT
id,
CASE WHEN delete_epoch IS NOT NULL THEN
_prom_catalog.resurrect_series_ids(%1$L, id)
END
FROM prom_data_series.%1$I as series
WHERE labels = (SELECT * FROM cte)
)
SELECT id FROM existing
UNION ALL
SELECT _prom_catalog.create_series(%2$L, %1$L, (SELECT * FROM cte))
LIMIT 1
$query$, table_name, metric_id)
USING label
INTO series_id;
RETURN series_id;
END
$$
LANGUAGE PLPGSQL VOLATILE;
COMMENT ON FUNCTION _prom_catalog.get_or_create_series_id(jsonb)
IS 'returns the series id that exactly matches a JSONB of labels';
GRANT EXECUTE ON FUNCTION _prom_catalog.get_or_create_series_id(jsonb) TO prom_writer;
CREATE OR REPLACE FUNCTION _prom_catalog.get_or_create_series_id_for_kv_array(metric_name TEXT, label_keys text[], label_values text[], OUT table_name NAME, OUT series_id BIGINT)
AS $func$
DECLARE
metric_id int;
BEGIN
--need to make sure the series partition exists
SELECT mtn.id, mtn.table_name FROM _prom_catalog.get_or_create_metric_table_name(metric_name) mtn
INTO metric_id, table_name;
-- the data table could be locked during label key creation
-- and must be locked before the series parent according to lock ordering
EXECUTE format($query$
LOCK TABLE ONLY prom_data.%1$I IN ACCESS SHARE MODE
$query$, table_name);
EXECUTE format($query$
WITH cte AS (
SELECT _prom_catalog.get_or_create_label_array($1, $2, $3)
), existing AS (
SELECT
id,
CASE WHEN delete_epoch IS NOT NULL THEN
_prom_catalog.resurrect_series_ids(%1$L, id)
END
FROM prom_data_series.%1$I as series
WHERE labels = (SELECT * FROM cte)
)
SELECT id FROM existing
UNION ALL
SELECT _prom_catalog.create_series(%2$L, %1$L, (SELECT * FROM cte))
LIMIT 1
$query$, table_name, metric_id)
USING metric_name, label_keys, label_values
INTO series_id;
RETURN;
END
$func$
LANGUAGE PLPGSQL VOLATILE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_or_create_series_id_for_kv_array(TEXT, text[], text[]) TO prom_writer;
CREATE OR REPLACE FUNCTION _prom_catalog.get_or_create_series_id_for_label_array(metric_id INT, table_name NAME, larray prom_api.label_array, OUT series_id BIGINT)
AS $func$
BEGIN
EXECUTE format($query$
WITH existing AS (
SELECT
id,
CASE WHEN delete_epoch IS NOT NULL THEN
_prom_catalog.resurrect_series_ids(%1$L, id)
END
FROM prom_data_series.%1$I as series
WHERE labels = $1
)
SELECT id FROM existing
UNION ALL
SELECT _prom_catalog.create_series(%2$L, %1$L, $1)
LIMIT 1
$query$, table_name, metric_id)
USING larray
INTO series_id;
RETURN;
END
$func$
LANGUAGE PLPGSQL VOLATILE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_or_create_series_id_for_label_array(INT, NAME, prom_api.label_array) TO prom_writer;
--
-- Parameter manipulation functions
--
CREATE OR REPLACE FUNCTION _prom_catalog.set_chunk_interval_on_metric_table(metric_name TEXT, new_interval INTERVAL)
RETURNS void
AS $func$
BEGIN
IF NOT _prom_catalog.is_timescaledb_installed() THEN
RAISE EXCEPTION 'cannot set chunk time interval without timescaledb installed';
END IF;
--set interval while adding 1% of randomness to the interval so that chunks are not aligned so that
--chunks are staggered for compression jobs.
EXECUTE public.set_chunk_time_interval(
format('prom_data.%I',(SELECT table_name FROM _prom_catalog.get_or_create_metric_table_name(metric_name)))::regclass,
_prom_catalog.get_staggered_chunk_interval(new_interval));
END
$func$
LANGUAGE PLPGSQL VOLATILE
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION _prom_catalog.set_chunk_interval_on_metric_table(TEXT, INTERVAL) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.set_chunk_interval_on_metric_table(TEXT, INTERVAL) TO prom_admin;
CREATE OR REPLACE FUNCTION prom_api.set_default_chunk_interval(chunk_interval INTERVAL)
RETURNS BOOLEAN
AS $$
INSERT INTO _prom_catalog.default(key, value) VALUES('chunk_interval', chunk_interval::text)
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value;
SELECT _prom_catalog.set_chunk_interval_on_metric_table(metric_name, chunk_interval)
FROM _prom_catalog.metric
WHERE default_chunk_interval;
SELECT true;
$$
LANGUAGE SQL VOLATILE;
COMMENT ON FUNCTION prom_api.set_default_chunk_interval(INTERVAL)
IS 'set the chunk interval for any metrics (existing and new) without an explicit override';
GRANT EXECUTE ON FUNCTION prom_api.set_default_chunk_interval(INTERVAL) TO prom_admin;
CREATE OR REPLACE FUNCTION prom_api.set_metric_chunk_interval(metric_name TEXT, chunk_interval INTERVAL)
RETURNS BOOLEAN
AS $func$
--use get_or_create_metric_table_name because we want to be able to set /before/ any data is ingested
--needs to run before update so row exists before update.
SELECT _prom_catalog.get_or_create_metric_table_name(set_metric_chunk_interval.metric_name);
UPDATE _prom_catalog.metric SET default_chunk_interval = false
WHERE id IN (SELECT id FROM _prom_catalog.get_metric_table_name_if_exists('prom_data', set_metric_chunk_interval.metric_name));
SELECT _prom_catalog.set_chunk_interval_on_metric_table(metric_name, chunk_interval);
SELECT true;
$func$
LANGUAGE SQL VOLATILE;
COMMENT ON FUNCTION prom_api.set_metric_chunk_interval(TEXT, INTERVAL)
IS 'set a chunk interval for a specific metric (this overrides the default)';
GRANT EXECUTE ON FUNCTION prom_api.set_metric_chunk_interval(TEXT, INTERVAL) TO prom_admin;
CREATE OR REPLACE FUNCTION prom_api.reset_metric_chunk_interval(metric_name TEXT)
RETURNS BOOLEAN
AS $func$
UPDATE _prom_catalog.metric SET default_chunk_interval = true
WHERE id = (SELECT id FROM _prom_catalog.get_metric_table_name_if_exists('prom_data', metric_name));
SELECT _prom_catalog.set_chunk_interval_on_metric_table(metric_name,
_prom_catalog.get_default_chunk_interval());
SELECT true;
$func$
LANGUAGE SQL VOLATILE;
COMMENT ON FUNCTION prom_api.reset_metric_chunk_interval(TEXT)
IS 'resets the chunk interval for a specific metric to using the default';
GRANT EXECUTE ON FUNCTION prom_api.reset_metric_chunk_interval(TEXT) TO prom_admin;
CREATE OR REPLACE FUNCTION _prom_catalog.get_metric_retention_period(schema_name TEXT, metric_name TEXT)
RETURNS INTERVAL
AS $$
SELECT COALESCE(m.retention_period, _prom_catalog.get_default_retention_period())
FROM _prom_catalog.metric m
WHERE id IN (SELECT id FROM _prom_catalog.get_metric_table_name_if_exists(schema_name, get_metric_retention_period.metric_name))
UNION ALL
SELECT _prom_catalog.get_default_retention_period()
LIMIT 1
$$
LANGUAGE SQL STABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_metric_retention_period(TEXT, TEXT) TO prom_reader;
-- convenience function for returning retention period of raw metrics
-- without the need to specify the schema
CREATE OR REPLACE FUNCTION _prom_catalog.get_metric_retention_period(metric_name TEXT)
RETURNS INTERVAL
AS $$
SELECT *
FROM _prom_catalog.get_metric_retention_period('prom_data', metric_name)
$$
LANGUAGE SQL STABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_metric_retention_period(TEXT) TO prom_reader;
CREATE OR REPLACE FUNCTION prom_api.set_default_retention_period(retention_period INTERVAL)
RETURNS BOOLEAN
AS $$
INSERT INTO _prom_catalog.default(key, value) VALUES('retention_period', retention_period::text)
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value;
SELECT true;
$$
LANGUAGE SQL VOLATILE;
COMMENT ON FUNCTION prom_api.set_default_retention_period(INTERVAL)
IS 'set the retention period for any metrics (existing and new) without an explicit override';
GRANT EXECUTE ON FUNCTION prom_api.set_default_retention_period(INTERVAL) TO prom_admin;
CREATE OR REPLACE FUNCTION prom_api.set_metric_retention_period(schema_name TEXT, metric_name TEXT, new_retention_period INTERVAL)
RETURNS BOOLEAN
AS $func$
DECLARE
r _prom_catalog.metric;
_is_cagg BOOLEAN;
_cagg_schema NAME;
_cagg_name NAME;
BEGIN
--use get_or_create_metric_table_name because we want to be able to set /before/ any data is ingested
--needs to run before update so row exists before update.
PERFORM _prom_catalog.get_or_create_metric_table_name(set_metric_retention_period.metric_name)
WHERE schema_name = 'prom_data';
--check if its a metric view with cagg
SELECT is_cagg, cagg_schema, cagg_name
INTO _is_cagg, _cagg_schema, _cagg_name
FROM _prom_catalog.get_cagg_info(schema_name, metric_name);
IF NOT _is_cagg OR (_cagg_name = metric_name AND _cagg_schema = schema_name) THEN
UPDATE _prom_catalog.metric m SET retention_period = new_retention_period
WHERE m.table_schema = schema_name
AND m.metric_name = set_metric_retention_period.metric_name;
RETURN true;
END IF;
--handles 2-step aggregatop
RAISE NOTICE 'Setting data retention period for all metrics with underlying continuous aggregate %.%', _cagg_schema, _cagg_name;
FOR r IN
SELECT m.*
FROM information_schema.view_table_usage v
INNER JOIN _prom_catalog.metric m
ON (m.table_name = v.view_name AND m.table_schema = v.view_schema)
WHERE v.table_name = _cagg_name
AND v.table_schema = _cagg_schema
LOOP
RAISE NOTICE 'Setting data retention for metrics %.%', r.table_schema, r.metric_name;
UPDATE _prom_catalog.metric m
SET retention_period = new_retention_period
WHERE m.table_schema = r.table_schema
AND m.metric_name = r.metric_name;
END LOOP;
RETURN true;
END
$func$
LANGUAGE PLPGSQL VOLATILE;
COMMENT ON FUNCTION prom_api.set_metric_retention_period(TEXT, TEXT, INTERVAL)
IS 'set a retention period for a specific metric (this overrides the default)';
GRANT EXECUTE ON FUNCTION prom_api.set_metric_retention_period(TEXT, TEXT, INTERVAL)TO prom_admin;
CREATE OR REPLACE FUNCTION prom_api.set_metric_retention_period(metric_name TEXT, new_retention_period INTERVAL)
RETURNS BOOLEAN
AS $func$
SELECT prom_api.set_metric_retention_period('prom_data', metric_name, new_retention_period);
$func$
LANGUAGE SQL VOLATILE;
COMMENT ON FUNCTION prom_api.set_metric_retention_period(TEXT, INTERVAL)
IS 'set a retention period for a specific raw metric in default schema (this overrides the default)';
GRANT EXECUTE ON FUNCTION prom_api.set_metric_retention_period(TEXT, INTERVAL)TO prom_admin;
CREATE OR REPLACE FUNCTION prom_api.reset_metric_retention_period(schema_name TEXT, metric_name TEXT)
RETURNS BOOLEAN
AS $func$
DECLARE
r _prom_catalog.metric;
_is_cagg BOOLEAN;
_cagg_schema NAME;
_cagg_name NAME;
BEGIN
--check if its a metric view with cagg
SELECT is_cagg, cagg_schema, cagg_name
INTO _is_cagg, _cagg_schema, _cagg_name
FROM _prom_catalog.get_cagg_info(schema_name, metric_name);
IF NOT _is_cagg OR (_cagg_name = metric_name AND _cagg_schema = schema_name) THEN
UPDATE _prom_catalog.metric m SET retention_period = NULL
WHERE m.table_schema = schema_name
AND m.metric_name = reset_metric_retention_period.metric_name;
RETURN true;
END IF;
RAISE NOTICE 'Resetting data retention period for all metrics with underlying continuous aggregate %.%', _cagg_schema, cagg_name;
FOR r IN
SELECT m.*
FROM information_schema.view_table_usage v
INNER JOIN _prom_catalog.metric m
ON (m.table_name = v.view_name AND m.table_schema = v.view_schema)
WHERE v.table_name = _cagg_name
AND v.table_schema = _cagg_schem
LOOP
RAISE NOTICE 'Resetting data retention for metrics %.%', r.table_schema, r.metric_name;
UPDATE _prom_catalog.metric m
SET retention_period = NULL
WHERE m.table_schema = r.table_schema
AND m.metric_name = r.metric_name;
END LOOP;
RETURN true;
END
$func$
LANGUAGE PLPGSQL VOLATILE;
COMMENT ON FUNCTION prom_api.reset_metric_retention_period(TEXT, TEXT)
IS 'resets the retention period for a specific metric to using the default';
GRANT EXECUTE ON FUNCTION prom_api.reset_metric_retention_period(TEXT, TEXT) TO prom_admin;
CREATE OR REPLACE FUNCTION prom_api.reset_metric_retention_period(metric_name TEXT)
RETURNS BOOLEAN
AS $func$
SELECT prom_api.reset_metric_retention_period('prom_data', metric_name);
$func$
LANGUAGE SQL VOLATILE;
COMMENT ON FUNCTION prom_api.reset_metric_retention_period(TEXT)
IS 'resets the retention period for a specific raw metric in the default schema to using the default retention period';
GRANT EXECUTE ON FUNCTION prom_api.reset_metric_retention_period(TEXT) TO prom_admin;
CREATE OR REPLACE FUNCTION _prom_catalog.get_metric_compression_setting(metric_name TEXT)
RETURNS BOOLEAN
AS $$
DECLARE
can_compress boolean;
result boolean;
metric_table_name text;
BEGIN
SELECT exists(select * from pg_proc where proname = 'compress_chunk')
INTO STRICT can_compress;
IF NOT can_compress THEN
RETURN FALSE;
END IF;
SELECT table_name
INTO STRICT metric_table_name
FROM _prom_catalog.get_metric_table_name_if_exists('prom_data', metric_name);
IF _prom_catalog.get_timescale_major_version() >= 2 THEN
SELECT compression_enabled
FROM timescaledb_information.hypertables
WHERE hypertable_schema ='prom_data'
AND hypertable_name = metric_table_name
INTO STRICT result;
ELSE
SELECT EXISTS (
SELECT FROM _timescaledb_catalog.hypertable h
WHERE h.schema_name = 'prom_data'
AND h.table_name = metric_table_name
AND h.compressed_hypertable_id IS NOT NULL)
INTO result;
END IF;
RETURN result;
END
$$
LANGUAGE PLPGSQL STABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_metric_compression_setting(TEXT) TO prom_reader;
CREATE OR REPLACE FUNCTION prom_api.set_default_compression_setting(compression_setting BOOLEAN)
RETURNS BOOLEAN
AS $$
DECLARE
can_compress BOOLEAN;
BEGIN
IF compression_setting = _prom_catalog.get_default_compression_setting() THEN
RETURN TRUE;
END IF;
SELECT exists(select * from pg_proc where proname = 'compress_chunk')
INTO STRICT can_compress;
IF NOT can_compress AND compression_setting THEN
RAISE EXCEPTION 'Cannot enable metrics compression, feature not found';
END IF;
INSERT INTO _prom_catalog.default(key, value) VALUES('metric_compression', compression_setting::text)
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value;
PERFORM prom_api.set_compression_on_metric_table(table_name, compression_setting)
FROM _prom_catalog.metric
WHERE default_compression;
RETURN true;
END
$$
LANGUAGE PLPGSQL VOLATILE;
COMMENT ON FUNCTION prom_api.set_default_compression_setting(BOOLEAN)
IS 'set the compression setting for any metrics (existing and new) without an explicit override';
GRANT EXECUTE ON FUNCTION prom_api.set_default_compression_setting(BOOLEAN) TO prom_admin;
CREATE OR REPLACE FUNCTION prom_api.set_metric_compression_setting(metric_name TEXT, new_compression_setting BOOLEAN)
RETURNS BOOLEAN
AS $func$
DECLARE
can_compress boolean;
metric_table_name text;
BEGIN
--if already set to desired value, nothing to do
IF _prom_catalog.get_metric_compression_setting(metric_name) = new_compression_setting THEN
RETURN TRUE;
END IF;
SELECT exists(select * from pg_proc where proname = 'compress_chunk')
INTO STRICT can_compress;
--if compression is missing, cannot enable it
IF NOT can_compress AND new_compression_setting THEN
RAISE EXCEPTION 'Cannot enable metrics compression, feature not found';
END IF;
--use get_or_create_metric_table_name because we want to be able to set /before/ any data is ingested
--needs to run before update so row exists before update.
SELECT table_name
INTO STRICT metric_table_name
FROM _prom_catalog.get_or_create_metric_table_name(set_metric_compression_setting.metric_name);
PERFORM prom_api.set_compression_on_metric_table(metric_table_name, new_compression_setting);
UPDATE _prom_catalog.metric
SET default_compression = false
WHERE table_name = metric_table_name;
RETURN true;
END
$func$
LANGUAGE PLPGSQL VOLATILE;
COMMENT ON FUNCTION prom_api.set_metric_compression_setting(TEXT, BOOLEAN)
IS 'set a compression setting for a specific metric (this overrides the default)';
GRANT EXECUTE ON FUNCTION prom_api.set_metric_compression_setting(TEXT, BOOLEAN) TO prom_admin;
CREATE OR REPLACE FUNCTION prom_api.set_compression_on_metric_table(metric_table_name TEXT, compression_setting BOOLEAN)
RETURNS void
AS $func$
DECLARE
BEGIN
IF _prom_catalog.is_timescaledb_oss() THEN
RAISE NOTICE 'Compression not available in TimescaleDB-OSS. Cannot set compression on "%" metric table name', metric_table_name;
RETURN;
END IF;
IF compression_setting THEN
EXECUTE format($$
ALTER TABLE prom_data.%I SET (
timescaledb.compress,
timescaledb.compress_segmentby = 'series_id',
timescaledb.compress_orderby = 'time, value'
); $$, metric_table_name);
--rc4 of multinode doesn't properly hand down compression when turned on
--inside of a function; this gets around that.
IF _prom_catalog.is_multinode() THEN
CALL public.distributed_exec(
format($$
ALTER TABLE prom_data.%I SET (
timescaledb.compress,
timescaledb.compress_segmentby = 'series_id',
timescaledb.compress_orderby = 'time, value'
); $$, metric_table_name),
transactional => false);
END IF;
--chunks where the end time is before now()-1 hour will be compressed
--per-ht compression policy only used for timescale 1.x
IF _prom_catalog.get_timescale_major_version() < 2 THEN
PERFORM public.add_compress_chunks_policy(format('prom_data.%I', metric_table_name), INTERVAL '1 hour');
END IF;
ELSE
IF _prom_catalog.get_timescale_major_version() < 2 THEN
PERFORM public.remove_compress_chunks_policy(format('prom_data.%I', metric_table_name));
END IF;
CALL _prom_catalog.decompress_chunks_after(metric_table_name::name, timestamptz '-Infinity', transactional=>true);
EXECUTE format($$
ALTER TABLE prom_data.%I SET (
timescaledb.compress = false
); $$, metric_table_name);
END IF;
END
$func$
LANGUAGE PLPGSQL VOLATILE
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION prom_api.set_compression_on_metric_table(TEXT, BOOLEAN) FROM PUBLIC;
COMMENT ON FUNCTION prom_api.set_compression_on_metric_table(TEXT, BOOLEAN)
IS 'set a compression for a specific metric table';
GRANT EXECUTE ON FUNCTION prom_api.set_compression_on_metric_table(TEXT, BOOLEAN) TO prom_admin;
CREATE OR REPLACE FUNCTION prom_api.reset_metric_compression_setting(metric_name TEXT)
RETURNS BOOLEAN
AS $func$
DECLARE
metric_table_name text;
BEGIN
SELECT table_name
INTO STRICT metric_table_name
FROM _prom_catalog.get_or_create_metric_table_name(reset_metric_compression_setting.metric_name);
UPDATE _prom_catalog.metric
SET default_compression = true
WHERE table_name = metric_table_name;
PERFORM prom_api.set_compression_on_metric_table(metric_table_name, _prom_catalog.get_default_compression_setting());
RETURN true;
END
$func$
LANGUAGE PLPGSQL VOLATILE;
COMMENT ON FUNCTION prom_api.reset_metric_compression_setting(TEXT)
IS 'resets the compression setting for a specific metric to using the default';
GRANT EXECUTE ON FUNCTION prom_api.reset_metric_compression_setting(TEXT) TO prom_admin;
CREATE OR REPLACE FUNCTION _prom_catalog.epoch_abort(user_epoch BIGINT)
RETURNS VOID AS $func$
DECLARE db_epoch BIGINT;
BEGIN
SELECT current_epoch FROM ids_epoch LIMIT 1
INTO db_epoch;
RAISE EXCEPTION 'epoch % to old to continue INSERT, current: %',
user_epoch, db_epoch
USING ERRCODE='PS001';
END;
$func$ LANGUAGE PLPGSQL VOLATILE;
COMMENT ON FUNCTION _prom_catalog.epoch_abort(BIGINT)
IS 'ABORT an INSERT transaction due to the ID epoch being out of date';
GRANT EXECUTE ON FUNCTION _prom_catalog.epoch_abort TO prom_writer;
CREATE OR REPLACE FUNCTION _prom_catalog.get_confirmed_unused_series(
metric_schema NAME, metric_table NAME, series_table NAME, potential_series_ids BIGINT[], check_time TIMESTAMPTZ
) RETURNS BIGINT[]
AS $func$
DECLARE
r RECORD;
check_time_condition TEXT;
BEGIN
FOR r IN
SELECT *
FROM _prom_catalog.metric m
WHERE m.series_table = get_confirmed_unused_series.series_table
LOOP
check_time_condition := '';
IF r.table_schema = metric_schema::NAME AND r.table_name = metric_table::NAME THEN
check_time_condition := FORMAT('AND time >= %L', check_time);
END IF;
--at each iteration of the loop filter potential_series_ids to only
--have those series ids that don't exist in the metric tables.
EXECUTE format(
$query$
SELECT array_agg(potential_series.series_id)
FROM unnest($1) as potential_series(series_id)
LEFT JOIN LATERAL(
SELECT 1
FROM %1$I.%2$I data_exists
WHERE data_exists.series_id = potential_series.series_id
%3$s
--use chunk append + more likely to find something starting at earliest time
ORDER BY time ASC
LIMIT 1
) as lateral_exists(indicator) ON (true)
WHERE lateral_exists.indicator IS NULL
$query$, r.table_schema, r.table_name, check_time_condition)
USING potential_series_ids
INTO potential_series_ids;
END LOOP;
RETURN potential_series_ids;
END
$func$
LANGUAGE PLPGSQL STABLE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_confirmed_unused_series(NAME, NAME, NAME, BIGINT[], TIMESTAMPTZ) TO prom_maintenance;
CREATE OR REPLACE FUNCTION _prom_catalog.mark_unused_series(
metric_schema TEXT, metric_table TEXT, metric_series_table TEXT, older_than TIMESTAMPTZ, check_time TIMESTAMPTZ
) RETURNS VOID AS $func$
DECLARE
BEGIN
--chances are that the hour after the drop point will have the most similar
--series to what is dropped, so first filter by all series that have been dropped
--but that aren't in that first hour and then make sure they aren't in the dataset
EXECUTE format(
$query$
WITH potentially_drop_series AS (
SELECT distinct series_id
FROM %1$I.%2$I
WHERE time < %4$L
EXCEPT
SELECT distinct series_id
FROM %1$I.%2$I
WHERE time >= %4$L AND time < %5$L
), confirmed_drop_series AS (
SELECT _prom_catalog.get_confirmed_unused_series('%1$s','%2$s','%3$s', array_agg(series_id), %5$L) as ids
FROM potentially_drop_series
) -- we want this next statement to be the last one in the txn since it could block series fetch (both of them update delete_epoch)
UPDATE prom_data_series.%3$I SET delete_epoch = current_epoch+1
FROM _prom_catalog.ids_epoch
WHERE delete_epoch IS NULL
AND id IN (SELECT unnest(ids) FROM confirmed_drop_series)
$query$, metric_schema, metric_table, metric_series_table, older_than, check_time);
END
$func$
LANGUAGE PLPGSQL VOLATILE
--security definer to add jobs as the logged-in user
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION _prom_catalog.mark_unused_series(text, text, text, timestamptz, timestamptz) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.mark_unused_series(text, text, text, timestamptz, timestamptz) TO prom_maintenance;
CREATE OR REPLACE FUNCTION _prom_catalog.delete_expired_series(
metric_schema TEXT, metric_table TEXT, metric_series_table TEXT, ran_at TIMESTAMPTZ, present_epoch BIGINT, last_updated_epoch TIMESTAMPTZ
) RETURNS VOID AS $func$
DECLARE
label_array int[];
next_epoch BIGINT;
deletion_epoch BIGINT;
BEGIN
next_epoch := present_epoch + 1;
-- technically we can delete any ID <= current_epoch - 1
-- but it's always safe to leave them around for a bit longer
deletion_epoch := present_epoch - 4;
-- we don't want to delete too soon
IF ran_at < last_updated_epoch + '1 hour' THEN
RETURN;
END IF;
EXECUTE format($query$
-- recheck that the series IDs we might delete are actually dead
WITH dead_series AS (
SELECT potential.id
FROM
(
SELECT id
FROM prom_data_series.%3$I
WHERE delete_epoch <= %4$L
) as potential
LEFT JOIN LATERAL (
SELECT 1
FROM %1$I.%2$I metric_data
WHERE metric_data.series_id = potential.id
LIMIT 1
) as lateral_exists(indicator) ON (TRUE)
WHERE indicator IS NULL
), deleted_series AS (
DELETE FROM prom_data_series.%3$I
WHERE delete_epoch <= %4$L
AND id IN (SELECT id FROM dead_series) -- concurrency means we need this qual in both
RETURNING id, labels
), resurrected_series AS (
UPDATE prom_data_series.%3$I
SET delete_epoch = NULL
WHERE delete_epoch <= %4$L
AND id NOT IN (SELECT id FROM dead_series) -- concurrency means we need this qual in both
)
SELECT ARRAY(SELECT DISTINCT unnest(labels) as label_id
FROM deleted_series)
$query$, metric_schema, metric_table, metric_series_table, deletion_epoch) INTO label_array;
IF array_length(label_array, 1) > 0 THEN
--jit interacts poorly why the multi-partition query below
SET LOCAL jit = 'off';
--needs to be a separate query and not a CTE since this needs to "see"
--the series rows deleted above as deleted.
--Note: we never delete metric name keys since there are check constraints that
--rely on those ids not changing.
EXECUTE format($query$
WITH check_local_series AS (
--the series table from which we just deleted is much more likely to have the label, so check that first to exclude most labels.
SELECT label_id
FROM unnest($1) as labels(label_id)
WHERE NOT EXISTS (
SELECT 1
FROM prom_data_series.%1$I series_exists_local
WHERE series_exists_local.labels && ARRAY[labels.label_id]
LIMIT 1
)
),
confirmed_drop_labels AS (
--do the global check to confirm
SELECT label_id
FROM check_local_series
WHERE NOT EXISTS (
SELECT 1
FROM _prom_catalog.series series_exists
WHERE series_exists.labels && ARRAY[label_id]
LIMIT 1
)
)
DELETE FROM _prom_catalog.label
WHERE id IN (SELECT * FROM confirmed_drop_labels) AND key != '__name__';
$query$, metric_series_table) USING label_array;
SET LOCAL jit = DEFAULT;
END IF;
UPDATE _prom_catalog.ids_epoch
SET (current_epoch, last_update_time) = (next_epoch, now())
WHERE current_epoch < next_epoch;
RETURN;
END
$func$
LANGUAGE PLPGSQL VOLATILE
--security definer to add jobs as the logged-in user
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION _prom_catalog.delete_expired_series(text, text, text, timestamptz, BIGINT, timestamptz) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.delete_expired_series(text, text, text, timestamptz, BIGINT, timestamptz) TO prom_maintenance;
CREATE OR REPLACE FUNCTION _prom_catalog.set_app_name(full_name text)
RETURNS VOID
AS $func$
--setting a name that's too long create surpurflous NOTICE messages in the log
SELECT set_config('application_name', substring(full_name for 63), false);
$func$
LANGUAGE SQL VOLATILE PARALLEL SAFE;
GRANT EXECUTE ON FUNCTION _prom_catalog.set_app_name(text) TO prom_maintenance;
-- Get hypertable information for where data is stored for raw metrics and for
-- the materialized hypertable for cagg metrics. For non-materialized views return
-- no rows
CREATE OR REPLACE FUNCTION _prom_catalog.get_storage_hypertable_info(metric_schema_name text, metric_table_name text, is_view boolean)
RETURNS TABLE (id int, hypertable_relation text)
AS $$
DECLARE
agg_schema name;
agg_name name;
_is_cagg boolean;
_materialized_hypertable_id int;
_storage_hypertable_relation text;
BEGIN
IF NOT _prom_catalog.is_timescaledb_installed() THEN
RETURN;
END IF;
IF NOT is_view THEN
RETURN QUERY
SELECT h.id, format('%I.%I', h.schema_name, h.table_name)
FROM _timescaledb_catalog.hypertable h
WHERE h.schema_name = metric_schema_name
AND h.table_name = metric_table_name;
RETURN;
END IF;
SELECT is_cagg, materialized_hypertable_id, storage_hypertable_relation
INTO _is_cagg, _materialized_hypertable_id, _storage_hypertable_relation
FROM _prom_catalog.get_cagg_info(metric_schema_name, metric_table_name);
IF NOT _is_cagg THEN
RETURN;
END IF;
RETURN QUERY SELECT _materialized_hypertable_id, _storage_hypertable_relation;
END
$$
LANGUAGE PLPGSQL STABLE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_storage_hypertable_info(text, text, boolean) TO prom_reader;
--Get underlying metric view schema and name
--we need to support up to two levels of views to support 2-step caggs
CREATE OR REPLACE FUNCTION _prom_catalog.get_first_level_view_on_metric(metric_schema text, metric_table text)
RETURNS TABLE (view_schema name, view_name name, metric_table_name name)
AS $$
BEGIN
--RAISE WARNING 'checking view: % %', metric_schema, metric_table;
RETURN QUERY
SELECT v.view_schema::name, v.view_name::name, v.table_name::name
FROM information_schema.view_table_usage v
WHERE v.view_schema = metric_schema
AND v.view_name = metric_table
AND v.table_schema = 'prom_data';
IF FOUND THEN
RETURN;
END IF;
-- if first level not found, return 2nd level if any
RETURN QUERY
SELECT v2.view_schema::name, v2.view_name::name, v2.table_name::name
FROM information_schema.view_table_usage v
LEFT JOIN information_schema.view_table_usage v2
ON (v2.view_schema = v.table_schema
AND v2.view_name = v.table_name)
WHERE v.view_schema = metric_schema
AND v.view_name = metric_table
AND v2.table_schema = 'prom_data';
RETURN;
END
$$
LANGUAGE PLPGSQL STABLE
--security definer to add jobs as the logged-in user
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION _prom_catalog.get_first_level_view_on_metric(text, text) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_first_level_view_on_metric(text, text) TO prom_reader;
CREATE OR REPLACE FUNCTION _prom_catalog.get_cagg_info(
metric_schema text, metric_table text,
OUT is_cagg BOOLEAN, OUT cagg_schema name, OUT cagg_name name, OUT metric_table_name name,
OUT materialized_hypertable_id INT, OUT storage_hypertable_relation TEXT)
AS $$
BEGIN
is_cagg := FALSE;
SELECT *
FROM _prom_catalog.get_first_level_view_on_metric(metric_schema, metric_table)
INTO cagg_schema, cagg_name, metric_table_name;
IF NOT FOUND THEN
RETURN;
END IF;
-- for TSDB 2.x we return the view schema and name because functions like
-- show_chunks don't work on materialized hypertables, which is a difference
-- from 1.x version
IF _prom_catalog.get_timescale_major_version() >= 2 THEN
SELECT h.id, format('%I.%I', c.view_schema, c.view_name)
INTO materialized_hypertable_id, storage_hypertable_relation
FROM timescaledb_information.continuous_aggregates c
INNER JOIN _timescaledb_catalog.hypertable h
ON (h.schema_name = c.materialization_hypertable_schema
AND h.table_name = c.materialization_hypertable_name)
WHERE c.view_schema = cagg_schema
AND c.view_name = cagg_name;
ELSE
SELECT h.id, format('%I.%I', h.schema_name, h.table_name)
INTO materialized_hypertable_id, storage_hypertable_relation
FROM timescaledb_information.continuous_aggregates c
INNER JOIN _timescaledb_catalog.hypertable h
ON (c.materialization_hypertable::text = format('%I.%I', h.schema_name, h.table_name))
WHERE c.view_name::text = format('%I.%I', cagg_schema, cagg_name);
END IF;
IF NOT FOUND THEN
cagg_schema := NULL;
cagg_name := NULL;
metric_table_name := NULL;
RETURN;
END IF;
is_cagg := true;
return;
END
$$
LANGUAGE PLPGSQL STABLE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_cagg_info(text, text) TO prom_reader;
CREATE OR REPLACE FUNCTION prom_api.is_stale_marker(value double precision)
RETURNS BOOLEAN
AS $func$
SELECT float8send(value) = '\x7ff0000000000002'
$func$
LANGUAGE SQL IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION prom_api.is_stale_marker(double precision)
IS 'returns true if the value is a Prometheus stale marker';
GRANT EXECUTE ON FUNCTION prom_api.is_stale_marker(double precision) TO prom_reader;
CREATE OR REPLACE FUNCTION prom_api.is_normal_nan(value double precision)
RETURNS BOOLEAN
AS $func$
SELECT float8send(value) = '\x7ff8000000000001'
$func$
LANGUAGE SQL IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION prom_api.is_normal_nan(double precision)
IS 'returns true if the value is a NaN';
GRANT EXECUTE ON FUNCTION prom_api.is_normal_nan(double precision) TO prom_reader;
CREATE OR REPLACE FUNCTION prom_api.val(
label_id INT)
RETURNS TEXT
AS $$
SELECT
value
FROM _prom_catalog.label
WHERE
id = label_id
$$
LANGUAGE SQL STABLE PARALLEL SAFE;
COMMENT ON FUNCTION prom_api.val(INT)
IS 'returns the label value from a label id';
GRANT EXECUTE ON FUNCTION prom_api.val(INT) TO prom_reader;
CREATE OR REPLACE FUNCTION _prom_catalog.get_label_key_column_name_for_view(label_key text, id BOOLEAN)
returns NAME
AS $func$
DECLARE
is_reserved boolean;
BEGIN
SELECT label_key = ANY(ARRAY['time', 'value', 'series_id', 'labels'])
INTO STRICT is_reserved;
IF is_reserved THEN
label_key := 'label_' || label_key;
END IF;
IF id THEN
RETURN (_prom_catalog.get_or_create_label_key(label_key)).id_column_name;
ELSE
RETURN (_prom_catalog.get_or_create_label_key(label_key)).value_column_name;
END IF;
END
$func$
LANGUAGE PLPGSQL VOLATILE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_label_key_column_name_for_view(text, BOOLEAN) TO prom_writer;
CREATE OR REPLACE FUNCTION _prom_catalog.create_series_view(
metric_name text)
RETURNS BOOLEAN
AS $func$
DECLARE
label_value_cols text;
view_name text;
metric_id int;
view_exists boolean;
BEGIN
SELECT
',' || string_agg(
format ('prom_api.val(series.labels[%s]) AS %I',pos::int, _prom_catalog.get_label_key_column_name_for_view(key, false))
, ', ' ORDER BY pos)
INTO STRICT label_value_cols
FROM _prom_catalog.label_key_position lkp
WHERE lkp.metric_name = create_series_view.metric_name and key != '__name__';
SELECT m.table_name, m.id
INTO STRICT view_name, metric_id
FROM _prom_catalog.metric m
WHERE m.metric_name = create_series_view.metric_name
AND m.table_schema = 'prom_data';
SELECT COUNT(*) > 0 into view_exists
FROM pg_class
WHERE
relname = view_name AND
relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'prom_series');
EXECUTE FORMAT($$
CREATE OR REPLACE VIEW prom_series.%1$I AS
SELECT
id AS series_id,
labels
%2$s
FROM
prom_data_series.%1$I AS series
WHERE delete_epoch IS NULL
$$, view_name, label_value_cols);
IF NOT view_exists THEN
EXECUTE FORMAT('GRANT SELECT ON prom_series.%1$I TO prom_reader', view_name);
END IF;
RETURN true;
END
$func$
LANGUAGE PLPGSQL VOLATILE
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION _prom_catalog.create_series_view(text) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.create_series_view(text) TO prom_writer;
CREATE OR REPLACE FUNCTION _prom_catalog.create_metric_view(
metric_name text)
RETURNS BOOLEAN
AS $func$
DECLARE
label_value_cols text;
table_name text;
metric_id int;
view_exists boolean;
BEGIN
SELECT
',' || string_agg(
format ('series.labels[%s] AS %I',pos::int, _prom_catalog.get_label_key_column_name_for_view(key, true))
, ', ' ORDER BY pos)
INTO STRICT label_value_cols
FROM _prom_catalog.label_key_position lkp
WHERE lkp.metric_name = create_metric_view.metric_name and key != '__name__';
SELECT m.table_name, m.id
INTO STRICT table_name, metric_id
FROM _prom_catalog.metric m
WHERE m.metric_name = create_metric_view.metric_name
AND m.table_schema = 'prom_data';
SELECT COUNT(*) > 0 into view_exists
FROM pg_class
WHERE
relname = table_name AND
relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'prom_metric');
EXECUTE FORMAT($$
CREATE OR REPLACE VIEW prom_metric.%1$I AS
SELECT
data.time as time,
data.value as value,
data.series_id AS series_id,
series.labels
%2$s
FROM
prom_data.%1$I AS data
LEFT JOIN prom_data_series.%1$I AS series ON (series.id = data.series_id)
$$, table_name, label_value_cols);
IF NOT view_exists THEN
EXECUTE FORMAT('GRANT SELECT ON prom_metric.%1$I TO prom_reader', table_name);
END IF;
RETURN true;
END
$func$
LANGUAGE PLPGSQL VOLATILE
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION _prom_catalog.create_metric_view(text) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.create_metric_view(text) TO prom_writer;
CREATE OR REPLACE FUNCTION prom_api.register_metric_view(schema_name name, view_name name, if_not_exists BOOLEAN = false)
RETURNS BOOLEAN
AS $func$
DECLARE
agg_schema name;
agg_name name;
metric_table_name name;
column_count int;
BEGIN
-- check if table/view exists
PERFORM * FROM information_schema.tables
WHERE table_schema = register_metric_view.schema_name
AND table_name = register_metric_view.view_name;
IF NOT FOUND THEN
RAISE EXCEPTION 'cannot register non-existant metric view in specified schema';
END IF;
-- cannot register view in data schema
IF schema_name = 'prom_data' THEN
RAISE EXCEPTION 'cannot register metric view in prom_data schema';
END IF;
-- check if view is based on a metric from prom_data
-- we check for two levels so we can support 2-step continuous aggregates
SELECT v.view_schema, v.view_name, v.metric_table_name
INTO agg_schema, agg_name, metric_table_name
FROM _prom_catalog.get_first_level_view_on_metric(schema_name, view_name) v;
IF NOT FOUND THEN
RAISE EXCEPTION 'view not based on a metric table from prom_data schema';
END IF;
-- check if the view contains necessary columns with the correct types
SELECT count(*) FROM information_schema.columns
INTO column_count
WHERE table_schema = register_metric_view.schema_name
AND table_name = register_metric_view.view_name
AND ((column_name = 'time' AND data_type = 'timestamp with time zone')
OR (column_name = 'series_id' AND data_type = 'bigint')
OR data_type = 'double precision');
IF column_count < 3 THEN
RAISE EXCEPTION 'view must contain time (data type: timestamp with time zone), series_id (data type: bigint), and at least one column with double precision data type';
END IF;
-- insert into metric table
INSERT INTO _prom_catalog.metric (metric_name, table_name, table_schema, series_table, is_view, creation_completed)
VALUES (register_metric_view.view_name, register_metric_view.view_name, register_metric_view.schema_name, metric_table_name, true, true)
ON CONFLICT DO NOTHING;
IF NOT FOUND THEN
IF register_metric_view.if_not_exists THEN
RAISE NOTICE 'metric with same name and schema already exists';
RETURN FALSE;
ELSE
RAISE EXCEPTION 'metric with the same name and schema already exists, could not register';
END IF;
END IF;
EXECUTE format('GRANT USAGE ON SCHEMA %I TO prom_reader', register_metric_view.schema_name);
EXECUTE format('GRANT SELECT ON TABLE %I.%I TO prom_reader', register_metric_view.schema_name, register_metric_view.view_name);
EXECUTE format('GRANT USAGE ON SCHEMA %I TO prom_reader', agg_schema);
EXECUTE format('GRANT SELECT ON TABLE %I.%I TO prom_reader', agg_schema, agg_name);
PERFORM *
FROM _prom_catalog.get_storage_hypertable_info(agg_schema, agg_name, true);
RETURN true;
END
$func$
LANGUAGE PLPGSQL VOLATILE
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION prom_api.register_metric_view(name, name, boolean) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION prom_api.register_metric_view(name, name, boolean) TO prom_admin;
CREATE OR REPLACE FUNCTION prom_api.unregister_metric_view(schema_name name, view_name name, if_exists BOOLEAN = false)
RETURNS BOOLEAN
AS $func$
DECLARE
metric_table_name name;
column_count int;
BEGIN
DELETE FROM _prom_catalog.metric
WHERE unregister_metric_view.schema_name = table_schema
AND unregister_metric_view.view_name = table_name
AND is_view = TRUE;
IF NOT FOUND THEN
IF unregister_metric_view.if_exists THEN
RAISE NOTICE 'metric with specified name and schema does not exist';
RETURN FALSE;
ELSE
RAISE EXCEPTION 'metric with specified name and schema does not exist, could not unregister';
END IF;
END IF;
RETURN TRUE;
END
$func$
LANGUAGE PLPGSQL VOLATILE
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION prom_api.unregister_metric_view(name, name, boolean) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION prom_api.unregister_metric_view(name, name, boolean) TO prom_admin;
CREATE OR REPLACE FUNCTION _prom_catalog.delete_series_from_metric(name text, series_ids bigint[])
RETURNS BIGINT
AS
$$
DECLARE
metric_table name;
delete_stmt text;
delete_query text;
rows_affected bigint;
num_rows_deleted bigint := 0;
BEGIN
SELECT table_name INTO metric_table FROM _prom_catalog.metric m WHERE m.metric_name=name AND m.is_view = false;
IF _prom_catalog.is_timescaledb_installed() THEN
FOR delete_stmt IN
SELECT FORMAT('DELETE FROM %1$I.%2$I WHERE series_id = ANY($1)', schema_name, table_name)
FROM (
SELECT (COALESCE(chc, ch)).* FROM pg_class c
INNER JOIN pg_namespace n ON c.relnamespace = n.oid
INNER JOIN _timescaledb_catalog.chunk ch ON (ch.schema_name, ch.table_name) = (n.nspname, c.relname)
LEFT JOIN _timescaledb_catalog.chunk chc ON ch.compressed_chunk_id = chc.id
WHERE c.oid IN (SELECT public.show_chunks(format('%I.%I','prom_data', metric_table))::oid)
) a
LOOP
EXECUTE delete_stmt USING series_ids;
GET DIAGNOSTICS rows_affected = ROW_COUNT;
num_rows_deleted = num_rows_deleted + rows_affected;
END LOOP;
ELSE
EXECUTE FORMAT('DELETE FROM prom_data.%1$I WHERE series_id = ANY($1)', metric_table) USING series_ids;
GET DIAGNOSTICS rows_affected = ROW_COUNT;
num_rows_deleted = num_rows_deleted + rows_affected;
END IF;
PERFORM _prom_catalog.delete_series_catalog_row(metric_table, series_ids);
RETURN num_rows_deleted;
END;
$$
LANGUAGE PLPGSQL VOLATILE
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION _prom_catalog.delete_series_from_metric(text, bigint[])FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.delete_series_from_metric(text, bigint[]) to prom_modifier;
-- the following functions require timescaledb >= 2.0.0
DO $block$
BEGIN
IF _prom_catalog.is_timescaledb_installed() AND _prom_catalog.get_timescale_major_version() >= 2 THEN
CREATE OR REPLACE FUNCTION _prom_catalog.hypertable_local_size(schema_name_in name)
RETURNS TABLE(hypertable_name name, table_bytes bigint, index_bytes bigint, toast_bytes bigint, total_bytes bigint)
AS $function$
BEGIN
IF _prom_catalog.get_timescale_minor_version() < 3 THEN
-- two columns in _timescaledb_internal.hypertable_chunk_local_size were renamed in version 2.2
-- schema_name -> hypertable_schema
-- table_name -> hypertable_name
-- we explicit aliases to deal with this
RETURN QUERY
SELECT
ch.hypertable_name,
(COALESCE(sum(ch.total_bytes), 0) - COALESCE(sum(ch.index_bytes), 0) - COALESCE(sum(ch.toast_bytes), 0) + COALESCE(sum(ch.compressed_heap_size), 0))::bigint + pg_relation_size(format('%I.%I', ch.hypertable_schema, ch.hypertable_name)::regclass)::bigint AS heap_bytes,
(COALESCE(sum(ch.index_bytes), 0) + COALESCE(sum(ch.compressed_index_size), 0))::bigint + pg_indexes_size(format('%I.%I', ch.hypertable_schema, ch.hypertable_name)::regclass)::bigint AS index_bytes,
(COALESCE(sum(ch.toast_bytes), 0) + COALESCE(sum(ch.compressed_toast_size), 0))::bigint AS toast_bytes,
(COALESCE(sum(ch.total_bytes), 0) + COALESCE(sum(ch.compressed_heap_size), 0) + COALESCE(sum(ch.compressed_index_size), 0) + COALESCE(sum(ch.compressed_toast_size), 0))::bigint + pg_total_relation_size(format('%I.%I', ch.hypertable_schema, ch.hypertable_name)::regclass)::bigint AS total_bytes
FROM _timescaledb_internal.hypertable_chunk_local_size ch
(
hypertable_schema,
hypertable_name,
hypertable_id,
chunk_id,
chunk_schema,
chunk_name,
total_bytes,
index_bytes,
toast_bytes,
compressed_heap_size,
compressed_index_size,
compressed_toast_size
)
WHERE ch.hypertable_schema = schema_name_in
GROUP BY ch.hypertable_name, ch.hypertable_schema;
ELSE
RETURN QUERY
SELECT
ch.hypertable_name,
(COALESCE(sum(ch.total_bytes), 0) - COALESCE(sum(ch.index_bytes), 0) - COALESCE(sum(ch.toast_bytes), 0) + COALESCE(sum(ch.compressed_heap_size), 0))::bigint + pg_relation_size(format('%I.%I', ch.hypertable_schema, ch.hypertable_name)::regclass)::bigint AS heap_bytes,
(COALESCE(sum(ch.index_bytes), 0) + COALESCE(sum(ch.compressed_index_size), 0))::bigint + pg_indexes_size(format('%I.%I', ch.hypertable_schema, ch.hypertable_name)::regclass)::bigint AS index_bytes,
(COALESCE(sum(ch.toast_bytes), 0) + COALESCE(sum(ch.compressed_toast_size), 0))::bigint AS toast_bytes,
(COALESCE(sum(ch.total_bytes), 0) + COALESCE(sum(ch.compressed_heap_size), 0) + COALESCE(sum(ch.compressed_index_size), 0) + COALESCE(sum(ch.compressed_toast_size), 0))::bigint + pg_total_relation_size(format('%I.%I', ch.hypertable_schema, ch.hypertable_name)::regclass)::bigint AS total_bytes
FROM _timescaledb_internal.hypertable_chunk_local_size ch
(
hypertable_schema,
hypertable_name,
hypertable_id,
chunk_id,
chunk_schema,
chunk_name,
total_bytes,
index_bytes,
toast_bytes,
compressed_total_size,
compressed_index_size,
compressed_toast_size,
compressed_heap_size
)
WHERE ch.hypertable_schema = schema_name_in
GROUP BY ch.hypertable_name, ch.hypertable_schema;
END IF;
END;
$function$
LANGUAGE plpgsql STRICT STABLE
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
REVOKE ALL ON FUNCTION _prom_catalog.hypertable_local_size(name) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.hypertable_local_size(name) to prom_reader;
CREATE OR REPLACE FUNCTION _prom_catalog.hypertable_node_up(schema_name_in name)
RETURNS TABLE(hypertable_name name, node_name name, node_up boolean)
AS $function$
-- list of distributed hypertables and whether or not the associated data node is up
-- only ping each distinct data node once and no more
-- there is no guarantee that a node will stay "up" for the duration of a transaction
-- but we don't want to pay the penalty of asking more than once, so we mark this
-- function as stable to allow the results to be cached
WITH dht AS MATERIALIZED (
-- list of distributed hypertables
SELECT
ht.table_name,
s.node_name
FROM _timescaledb_catalog.hypertable ht
JOIN _timescaledb_catalog.hypertable_data_node s ON (
ht.replication_factor > 0 AND s.hypertable_id = ht.id
)
WHERE ht.schema_name = schema_name_in
),
up AS MATERIALIZED (
-- list of nodes we care about and whether they are up
SELECT
x.node_name,
_timescaledb_internal.ping_data_node(x.node_name) AS node_up
FROM (
SELECT DISTINCT dht.node_name -- only ping each node once
FROM dht
) x
)
SELECT
dht.table_name as hypertable_name,
dht.node_name,
up.node_up
FROM dht
JOIN up ON (dht.node_name = up.node_name)
$function$
LANGUAGE sql
STRICT STABLE
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
REVOKE ALL ON FUNCTION _prom_catalog.hypertable_node_up(name) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.hypertable_node_up(name) to prom_reader;
CREATE OR REPLACE FUNCTION _prom_catalog.hypertable_remote_size(schema_name_in name)
RETURNS TABLE(hypertable_name name, table_bytes bigint, index_bytes bigint, toast_bytes bigint, total_bytes bigint)
AS $function$
SELECT
dht.hypertable_name,
sum(x.table_bytes)::bigint AS table_bytes,
sum(x.index_bytes)::bigint AS index_bytes,
sum(x.toast_bytes)::bigint AS toast_bytes,
sum(x.total_bytes)::bigint AS total_bytes
FROM _prom_catalog.hypertable_node_up(schema_name_in) dht
LEFT OUTER JOIN LATERAL _timescaledb_internal.data_node_hypertable_info(
CASE WHEN dht.node_up THEN
dht.node_name
ELSE
NULL
END, schema_name_in, dht.hypertable_name) x ON true
GROUP BY dht.hypertable_name
$function$
LANGUAGE sql
STRICT STABLE
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
REVOKE ALL ON FUNCTION _prom_catalog.hypertable_remote_size(name) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.hypertable_remote_size(name) to prom_reader;
-- two columns in _timescaledb_internal.compressed_chunk_stats were renamed in version 2.2
-- schema_name -> hypertable_schema
-- table_name -> hypertable_name
-- we use explicit column aliases on _timescaledb_internal.compressed_chunk_stats to rename the
-- `schema_name` and `table_name` in the older versions to the new names
CREATE OR REPLACE FUNCTION _prom_catalog.hypertable_compression_stats_for_schema(schema_name_in name)
RETURNS TABLE(hypertable_name name, total_chunks bigint, number_compressed_chunks bigint, before_compression_total_bytes bigint, after_compression_total_bytes bigint)
AS $function$
SELECT
x.hypertable_name,
count(*)::bigint AS total_chunks,
(count(*) FILTER (WHERE x.compression_status = 'Compressed'))::bigint AS number_compressed_chunks,
sum(x.before_compression_total_bytes)::bigint AS before_compression_total_bytes,
sum(x.after_compression_total_bytes)::bigint AS after_compression_total_bytes
FROM
(
-- local hypertables
SELECT
ch.hypertable_name,
ch.compression_status,
ch.uncompressed_total_size AS before_compression_total_bytes,
ch.compressed_total_size AS after_compression_total_bytes,
NULL::text AS node_name
FROM _timescaledb_internal.compressed_chunk_stats ch
(
hypertable_schema,
hypertable_name,
chunk_schema,
chunk_name,
compression_status,
uncompressed_heap_size,
uncompressed_index_size,
uncompressed_toast_size,
uncompressed_total_size,
compressed_heap_size,
compressed_index_size,
compressed_toast_size,
compressed_total_size
)
WHERE ch.hypertable_schema = schema_name_in
UNION ALL
-- distributed hypertables
SELECT
dht.hypertable_name,
ch.compression_status,
ch.before_compression_total_bytes,
ch.after_compression_total_bytes,
dht.node_name
FROM _prom_catalog.hypertable_node_up(schema_name_in) dht
LEFT OUTER JOIN LATERAL _timescaledb_internal.data_node_compressed_chunk_stats (
CASE WHEN dht.node_up THEN
dht.node_name
ELSE
NULL
END, schema_name_in, dht.hypertable_name) ch ON true
WHERE ch.chunk_name IS NOT NULL
) x
GROUP BY x.hypertable_name
$function$
LANGUAGE sql
STRICT STABLE
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
REVOKE ALL ON FUNCTION _prom_catalog.hypertable_compression_stats_for_schema(name) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.hypertable_compression_stats_for_schema(name) to prom_reader;
END IF;
END;
$block$
;
--------------------------------- Views --------------------------------
CREATE OR REPLACE FUNCTION _prom_catalog.metric_view()
RETURNS TABLE(id int, metric_name text, table_name name, label_keys text[], retention_period interval,
chunk_interval interval, compressed_interval interval, total_interval interval,
before_compression_bytes bigint, after_compression_bytes bigint,
total_size_bytes bigint, total_size text, compression_ratio numeric,
total_chunks bigint, compressed_chunks bigint)
AS $func$
BEGIN
IF NOT _prom_catalog.is_timescaledb_installed() THEN
RETURN QUERY
SELECT
i.id,
i.metric_name,
i.table_name,
i.label_keys,
i.retention_period,
i.chunk_interval,
NULL::interval compressed_interval,
NULL::interval total_interval,
pg_size_bytes(i.total_size) as before_compression_bytes,
NULL::bigint as after_compression_bytes,
pg_size_bytes(i.total_size) as total_size_bytes,
i.total_size,
i.compression_ratio,
i.total_chunks,
i.compressed_chunks
FROM
(
SELECT
m.id,
m.metric_name,
m.table_name,
ARRAY(
SELECT key
FROM _prom_catalog.label_key_position lkp
WHERE lkp.metric_name = m.metric_name
ORDER BY key) label_keys,
_prom_catalog.get_metric_retention_period(m.table_schema, m.metric_name) as retention_period,
NULL::interval as chunk_interval,
pg_size_pretty(pg_total_relation_size(format('prom_data.%I', m.table_name)::regclass)) as total_size,
0.0 as compression_ratio,
NULL::bigint as total_chunks,
NULL::bigint as compressed_chunks
FROM _prom_catalog.metric m
) AS i;
RETURN;
END IF;
IF _prom_catalog.get_timescale_major_version() >= 2 THEN
RETURN QUERY
WITH ci AS (
SELECT
hypertable_name as hypertable_name,
COALESCE(SUM(range_end-range_start) FILTER(WHERE is_compressed), INTERVAL '0') AS compressed_interval,
COALESCE(SUM(range_end-range_start), INTERVAL '0') AS total_interval
FROM timescaledb_information.chunks c
WHERE hypertable_schema='prom_data'
GROUP BY hypertable_schema, hypertable_name
)
SELECT
m.id,
m.metric_name,
m.table_name,
ARRAY(
SELECT key
FROM _prom_catalog.label_key_position lkp
WHERE lkp.metric_name = m.metric_name
ORDER BY key) label_keys,
_prom_catalog.get_metric_retention_period(m.table_schema, m.metric_name) as retention_period,
dims.time_interval as chunk_interval,
ci.compressed_interval,
ci.total_interval,
hcs.before_compression_total_bytes::bigint,
hcs.after_compression_total_bytes::bigint,
hs.total_bytes::bigint as total_size_bytes,
pg_size_pretty(hs.total_bytes::bigint) as total_size,
(1.0 - (hcs.after_compression_total_bytes::NUMERIC / hcs.before_compression_total_bytes::NUMERIC)) * 100 as compression_ratio,
hcs.total_chunks::BIGINT,
hcs.number_compressed_chunks::BIGINT as compressed_chunks
FROM _prom_catalog.metric m
LEFT JOIN
(
SELECT
x.hypertable_name
, sum(x.total_bytes::bigint) as total_bytes
FROM
(
SELECT *
FROM _prom_catalog.hypertable_local_size('prom_data')
UNION ALL
SELECT *
FROM _prom_catalog.hypertable_remote_size('prom_data')
) x
GROUP BY x.hypertable_name
) hs ON (hs.hypertable_name = m.table_name)
LEFT JOIN timescaledb_information.dimensions dims ON
(dims.hypertable_schema = 'prom_data' AND dims.hypertable_name = m.table_name)
LEFT JOIN _prom_catalog.hypertable_compression_stats_for_schema('prom_data') hcs ON (hcs.hypertable_name = m.table_name)
LEFT JOIN ci ON (ci.hypertable_name = m.table_name)
;
ELSE
RETURN QUERY
SELECT
m.id,
m.metric_name,
m.table_name,
ARRAY(
SELECT key
FROM _prom_catalog.label_key_position lkp
WHERE lkp.metric_name = m.metric_name
ORDER BY key
) label_keys,
_prom_catalog.get_metric_retention_period(m.table_schema, m.metric_name) as retention_period,
(
SELECT _timescaledb_internal.to_interval(interval_length)
FROM _timescaledb_catalog.dimension d
WHERE d.hypertable_id = h.id
ORDER BY d.id ASC LIMIT 1
) as chunk_interval,
ci.compressed_interval,
ci.total_interval,
pg_size_bytes(chs.uncompressed_total_bytes) as before_compression_bytes,
pg_size_bytes(chs.compressed_total_bytes) as after_compression_bytes,
pg_size_bytes(hi.total_size) as total_bytes,
hi.total_size as total_size,
(1.0 - (pg_size_bytes(chs.compressed_total_bytes)::numeric / pg_size_bytes(chs.uncompressed_total_bytes)::numeric)) * 100 as compression_ratio,
chs.total_chunks,
chs.number_compressed_chunks as compressed_chunks
FROM _prom_catalog.metric m
LEFT JOIN timescaledb_information.hypertable hi ON
(hi.table_schema = 'prom_data' AND hi.table_name = m.table_name)
LEFT JOIN timescaledb_information.compressed_hypertable_stats chs ON
(chs.hypertable_name = format('%I.%I', 'prom_data', m.table_name)::regclass)
LEFT JOIN _timescaledb_catalog.hypertable h ON
(h.schema_name = 'prom_data' AND h.table_name = m.table_name)
LEFT JOIN LATERAL
(
SELECT COALESCE(
SUM(
UPPER(rs.ranges[1]::TSTZRANGE) - LOWER(rs.ranges[1]::TSTZRANGE)
),
INTERVAL '0'
) total_interval,
COALESCE(
SUM(
UPPER(rs.ranges[1]::TSTZRANGE) - LOWER(rs.ranges[1]::TSTZRANGE)
) FILTER (WHERE cs.compression_status = 'Compressed'),
INTERVAL '0'
) compressed_interval
FROM public.chunk_relation_size_pretty(FORMAT('prom_data.%I', m.table_name)) rs
LEFT JOIN timescaledb_information.compressed_chunk_stats cs ON
(cs.chunk_name::text = rs.chunk_table::text)
) as ci ON TRUE;
END IF;
END
$func$
LANGUAGE PLPGSQL STABLE
SECURITY DEFINER
--search path must be set for security definer
--need to include public(the timescaledb schema) for some timescale functions to work.
SET search_path = public, pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION _prom_catalog.metric_view() FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.metric_view() TO prom_reader;
CREATE OR REPLACE VIEW prom_info.metric AS
SELECT
*
FROM _prom_catalog.metric_view();
GRANT SELECT ON prom_info.metric TO prom_reader;
CREATE OR REPLACE VIEW prom_info.label AS
SELECT
lk.key,
lk.value_column_name,
lk.id_column_name,
va.values as values,
cardinality(va.values) as num_values
FROM _prom_catalog.label_key lk
INNER JOIN LATERAL(SELECT key, array_agg(value ORDER BY value) as values FROM _prom_catalog.label GROUP BY key)
AS va ON (va.key = lk.key) ORDER BY num_values DESC;
GRANT SELECT ON prom_info.label TO prom_reader;
CREATE OR REPLACE VIEW prom_info.system_stats AS
SELECT
(
SELECT _prom_catalog.safe_approximate_row_count('_prom_catalog.series'::REGCLASS)
) AS num_series_approx,
(
SELECT count(*) FROM _prom_catalog.metric
) AS num_metric,
(
SELECT count(*) FROM _prom_catalog.label_key
) AS num_label_keys,
(
SELECT count(*) FROM _prom_catalog.label
) AS num_labels;
GRANT SELECT ON prom_info.system_stats TO prom_reader;
CREATE OR REPLACE VIEW prom_info.metric_stats AS
SELECT metric_name,
_prom_catalog.safe_approximate_row_count(format('prom_series.%I', table_name)::regclass) AS num_series_approx,
(SELECT _prom_catalog.safe_approximate_row_count(format('prom_data.%I',table_name)::regclass)) AS num_samples_approx
FROM _prom_catalog.metric ORDER BY metric_name;
GRANT SELECT ON prom_info.metric_stats TO prom_reader;
--this should the only thing run inside the transaction. It's important the txn ends after calling this function
--to release locks
CREATE OR REPLACE FUNCTION _prom_catalog.delay_compression_job(ht_table name, new_start timestamptz) RETURNS VOID
AS $$
DECLARE
bgw_job_id int;
BEGIN
UPDATE _prom_catalog.metric m
SET delay_compression_until = new_start
WHERE table_name = ht_table;
IF _prom_catalog.get_timescale_major_version() < 2 THEN
SELECT job_id INTO bgw_job_id
FROM _timescaledb_config.bgw_policy_compress_chunks p
INNER JOIN _timescaledb_catalog.hypertable h ON (h.id = p.hypertable_id)
WHERE h.schema_name = 'prom_data' and h.table_name = ht_table;
--alter job schedule is not currently concurrency-safe (timescaledb issue #2165)
PERFORM pg_advisory_xact_lock(_prom_catalog.get_advisory_lock_prefix_job(), bgw_job_id);
PERFORM public.alter_job_schedule(bgw_job_id, next_start=>GREATEST(new_start, (SELECT next_start FROM timescaledb_information.policy_stats WHERE job_id = bgw_job_id)));
END IF;
END
$$
LANGUAGE PLPGSQL
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
--redundant given schema settings but extra caution for security definers
REVOKE ALL ON FUNCTION _prom_catalog.delay_compression_job(name, timestamptz) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.delay_compression_job(name, timestamptz) TO prom_writer;
CALL _prom_catalog.execute_everywhere('_prom_catalog.do_decompress_chunks_after', $ee$
DO $DO$
BEGIN
--this function isolates the logic that needs to be security definer
--cannot fold it into do_decompress_chunks_after because cannot have security
--definer do txn-al stuff like commit
CREATE OR REPLACE FUNCTION _prom_catalog.decompress_chunk_for_metric(metric_table TEXT, chunk_schema_name name, chunk_table_name name) RETURNS VOID
AS $$
DECLARE
chunk_full_name text;
BEGIN
--double check chunk belongs to metric table
SELECT
format('%I.%I', c.schema_name, c.table_name)
INTO chunk_full_name
FROM _timescaledb_catalog.chunk c
INNER JOIN _timescaledb_catalog.hypertable h ON (h.id = c.hypertable_id)
WHERE
c.schema_name = chunk_schema_name AND c.table_name = chunk_table_name AND
h.schema_name = 'prom_data' AND h.table_name = metric_table AND
c.compressed_chunk_id IS NOT NULL;
IF NOT FOUND Then
RETURN;
END IF;
--lock the chunk exclusive.
EXECUTE format('LOCK %I.%I;', chunk_schema_name, chunk_table_name);
--double check it's still compressed.
PERFORM c.*
FROM _timescaledb_catalog.chunk c
WHERE schema_name = chunk_schema_name AND table_name = chunk_table_name AND
c.compressed_chunk_id IS NOT NULL;
IF NOT FOUND Then
RETURN;
END IF;
RAISE NOTICE 'Promscale is decompressing chunk: %.%', chunk_schema_name, chunk_table_name;
PERFORM public.decompress_chunk(chunk_full_name);
END;
$$
LANGUAGE PLPGSQL
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
REVOKE ALL ON FUNCTION _prom_catalog.decompress_chunk_for_metric(TEXT, name, name) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.decompress_chunk_for_metric(TEXT, name, name) TO prom_writer;
--Decompression should take place in a procedure because we don't want locks held across
--decompress_chunk calls since that function takes some heavier locks at the end.
--Thus, transactional parameter should usually be false
CREATE OR REPLACE PROCEDURE _prom_catalog.do_decompress_chunks_after(metric_table NAME, min_time TIMESTAMPTZ, transactional BOOLEAN = false)
AS $$
DECLARE
chunk_row record;
dimension_row record;
hypertable_row record;
min_time_internal bigint;
BEGIN
SELECT h.* INTO STRICT hypertable_row FROM _timescaledb_catalog.hypertable h
WHERE table_name = metric_table AND schema_name = 'prom_data';
SELECT d.* INTO STRICT dimension_row FROM _timescaledb_catalog.dimension d WHERE hypertable_id = hypertable_row.id ORDER BY id LIMIT 1;
IF min_time = timestamptz '-Infinity' THEN
min_time_internal := -9223372036854775808;
ELSE
SELECT _timescaledb_internal.time_to_internal(min_time) INTO STRICT min_time_internal;
END IF;
FOR chunk_row IN
SELECT c.*
FROM _timescaledb_catalog.dimension_slice ds
INNER JOIN _timescaledb_catalog.chunk_constraint cc ON cc.dimension_slice_id = ds.id
INNER JOIN _timescaledb_catalog.chunk c ON cc.chunk_id = c.id
WHERE dimension_id = dimension_row.id
-- the range_ends are non-inclusive
AND min_time_internal < ds.range_end
AND c.compressed_chunk_id IS NOT NULL
ORDER BY ds.range_start
LOOP
PERFORM _prom_catalog.decompress_chunk_for_metric(metric_table, chunk_row.schema_name, chunk_row.table_name);
IF NOT transactional THEN
COMMIT;
END IF;
END LOOP;
END;
$$ LANGUAGE PLPGSQL;
GRANT EXECUTE ON PROCEDURE _prom_catalog.do_decompress_chunks_after(NAME, TIMESTAMPTZ, BOOLEAN) TO prom_writer;
END
$DO$;
$ee$);
CREATE OR REPLACE PROCEDURE _prom_catalog.decompress_chunks_after(metric_table NAME, min_time TIMESTAMPTZ, transactional BOOLEAN = false)
AS $proc$
BEGIN
-- In early versions of timescale multinode the access node catalog does not
-- store whether chunks were compressed, so we need to run the actual search
-- for nodes in need of decompression on the data nodes, and /not/ the
-- access node; right now executing on the access node will do a lot of work
-- and locking for no result.
IF _prom_catalog.is_multinode() THEN
CALL public.distributed_exec(
format(
$dist$ CALL _prom_catalog.do_decompress_chunks_after(%L, %L, %L) $dist$,
metric_table, min_time, transactional),
transactional => false);
ELSE
CALL _prom_catalog.do_decompress_chunks_after(metric_table, min_time, transactional);
END IF;
END
$proc$ LANGUAGE PLPGSQL;
GRANT EXECUTE ON PROCEDURE _prom_catalog.decompress_chunks_after(name, TIMESTAMPTZ, boolean) TO prom_writer;
CALL _prom_catalog.execute_everywhere('_prom_catalog.compress_old_chunks', $ee$
DO $DO$
BEGIN
--this function isolates the logic that needs to be security definer
--cannot fold it into compress_old_chunks because cannot have security
--definer do txn-all stuff like commit
CREATE OR REPLACE FUNCTION _prom_catalog.compress_chunk_for_metric(metric_table TEXT, chunk_schema_name name, chunk_table_name name) RETURNS VOID
AS $$
DECLARE
chunk_full_name text;
BEGIN
SELECT
format('%I.%I', chunk_schema, chunk_name)
INTO chunk_full_name
FROM timescaledb_information.chunks
WHERE hypertable_schema = 'prom_data'
AND hypertable_name = metric_table
AND chunk_schema = chunk_schema_name
AND chunk_name = chunk_table_name;
PERFORM public.compress_chunk(chunk_full_name, if_not_compressed => true);
END;
$$
LANGUAGE PLPGSQL
SECURITY DEFINER
--search path must be set for security definer
SET search_path = pg_temp;
REVOKE ALL ON FUNCTION _prom_catalog.compress_chunk_for_metric(TEXT, name, name) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _prom_catalog.compress_chunk_for_metric(TEXT, name, name) TO prom_maintenance;
CREATE OR REPLACE PROCEDURE _prom_catalog.compress_old_chunks(metric_table TEXT, compress_before TIMESTAMPTZ)
AS $$
DECLARE
chunk_schema_name name;
chunk_table_name name;
chunk_range_end timestamptz;
chunk_num INT;
BEGIN
FOR chunk_schema_name, chunk_table_name, chunk_range_end, chunk_num IN
SELECT
chunk_schema,
chunk_name,
range_end,
row_number() OVER (ORDER BY range_end DESC)
FROM timescaledb_information.chunks
WHERE hypertable_schema = 'prom_data'
AND hypertable_name = metric_table
AND NOT is_compressed
ORDER BY range_end ASC
LOOP
CONTINUE WHEN chunk_num <= 1 OR chunk_range_end > compress_before;
PERFORM _prom_catalog.compress_chunk_for_metric(metric_table, chunk_schema_name, chunk_table_name);
COMMIT;
END LOOP;
END;
$$ LANGUAGE PLPGSQL;
GRANT EXECUTE ON PROCEDURE _prom_catalog.compress_old_chunks(TEXT, TIMESTAMPTZ) TO prom_maintenance;
END
$DO$;
$ee$);
CREATE OR REPLACE PROCEDURE _prom_catalog.compress_metric_chunks(metric_name TEXT)
AS $$
DECLARE
metric_table NAME;
BEGIN
SELECT table_name
INTO STRICT metric_table
FROM _prom_catalog.get_metric_table_name_if_exists('prom_data', metric_name);
-- as of timescaledb-2.0-rc4 the is_compressed column of the chunks view is
-- not updated on the access node, therefore we need to one the compressor
-- on all the datanodes to search for uncompressed chunks
IF _prom_catalog.is_multinode() THEN
CALL public.distributed_exec(format($dist$
CALL _prom_catalog.compress_old_chunks(%L, now() - INTERVAL '1 hour')
$dist$, metric_table), transactional => false);
ELSE
CALL _prom_catalog.compress_old_chunks(metric_table, now() - INTERVAL '1 hour');
END IF;
END
$$ LANGUAGE PLPGSQL;
GRANT EXECUTE ON PROCEDURE _prom_catalog.compress_metric_chunks(text) TO prom_maintenance;
--Order by random with stable marking gives us same order in a statement and different
-- orderings in different statements
CREATE OR REPLACE FUNCTION _prom_catalog.get_metrics_that_need_compression()
RETURNS SETOF _prom_catalog.metric
AS $$
DECLARE
BEGIN
RETURN QUERY
SELECT m.*
FROM _prom_catalog.metric m
WHERE
is_view = false AND
_prom_catalog.get_metric_compression_setting(m.metric_name) AND
delay_compression_until IS NULL OR delay_compression_until < now() AND
is_view = FALSE
ORDER BY random();
END
$$
LANGUAGE PLPGSQL STABLE;
GRANT EXECUTE ON FUNCTION _prom_catalog.get_metrics_that_need_compression() TO prom_maintenance;
--only for timescaledb 2.0 in 1.x we use compression policies
CREATE OR REPLACE PROCEDURE _prom_catalog.execute_compression_policy(log_verbose boolean = false)
AS $$
DECLARE
r _prom_catalog.metric;
remaining_metrics _prom_catalog.metric[] DEFAULT '{}';
startT TIMESTAMPTZ;
lockStartT TIMESTAMPTZ;
BEGIN
--Do one loop with metric that could be locked without waiting.
--This allows you to do everything you can while avoiding lock contention.
--Then come back for the metrics that would have needed to wait on the lock.
--Hopefully, that lock is now freed. The secoond loop waits for the lock
--to prevent starvation.
FOR r IN
SELECT *
FROM _prom_catalog.get_metrics_that_need_compression()
LOOP
IF NOT _prom_catalog.lock_metric_for_maintenance(r.id, wait=>false) THEN
remaining_metrics := remaining_metrics || r;
CONTINUE;
END IF;
IF log_verbose THEN
startT := clock_timestamp();
RAISE LOG 'promscale maintenance: compression: metric %: starting, without lock wait', r.metric_name;
END IF;
PERFORM _prom_catalog.set_app_name( format('promscale maintenance: compression: metric %s', r.metric_name));
CALL _prom_catalog.compress_metric_chunks(r.metric_name);
IF log_verbose THEN
RAISE LOG 'promscale maintenance: compression: metric %: finished in %', r.metric_name, clock_timestamp()-startT;
END IF;
PERFORM _prom_catalog.unlock_metric_for_maintenance(r.id);
COMMIT;
END LOOP;
FOR r IN
SELECT *
FROM unnest(remaining_metrics)
LOOP
IF log_verbose THEN
lockStartT := clock_timestamp();
RAISE LOG 'promscale maintenance: compression: metric %: waiting for lock', r.metric_name;
END IF;
PERFORM _prom_catalog.set_app_name( format('promscale maintenance: compression: metric %s: waiting on lock', r.metric_name));
PERFORM _prom_catalog.lock_metric_for_maintenance(r.id);
IF log_verbose THEN
startT := clock_timestamp();
RAISE LOG 'promscale maintenance: compression: metric %: starting', r.metric_name;
END IF;
PERFORM _prom_catalog.set_app_name( format('promscale maintenance: compression: metric %s', r.metric_name));
CALL _prom_catalog.compress_metric_chunks(r.metric_name);
IF log_verbose THEN
RAISE LOG 'promscale maintenance: compression: metric %: finished in % (lock took %; compression took %)', r.metric_name, clock_timestamp()-lockStartT, startT-lockStartT, clock_timestamp()-startT;
END IF;
PERFORM _prom_catalog.unlock_metric_for_maintenance(r.id);
COMMIT;
END LOOP;
END;
$$ LANGUAGE PLPGSQL;
COMMENT ON PROCEDURE _prom_catalog.execute_compression_policy(boolean)
IS 'compress data according to the policy. This procedure should be run regularly in a cron job';
GRANT EXECUTE ON PROCEDURE _prom_catalog.execute_compression_policy(boolean) TO prom_maintenance;
CREATE OR REPLACE PROCEDURE prom_api.add_prom_node(node_name TEXT, attach_to_existing_metrics BOOLEAN = true)
AS $func$
DECLARE
command_row record;
BEGIN
FOR command_row IN
SELECT command, transactional
FROM _prom_catalog.remote_commands
ORDER BY seq asc
LOOP
CALL public.distributed_exec(command_row.command,node_list=>array[node_name]);
END LOOP;
IF attach_to_existing_metrics THEN
PERFORM attach_data_node(node_name, hypertable => format('%I.%I', 'prom_data', table_name))
FROM _prom_catalog.metric;
END IF;
END
$func$ LANGUAGE PLPGSQL;
CREATE OR REPLACE FUNCTION _prom_catalog.insert_metric_row(
metric_table name,
time_array timestamptz[],
value_array DOUBLE PRECISION[],
series_id_array bigint[]
) RETURNS BIGINT AS
$$
DECLARE
num_rows BIGINT;
BEGIN
--turns out there is a horrible CPU perf penalty on the DB for ON CONFLICT DO NOTHING.
--yet in our data, conflicts are rare. So we first try inserting without ON CONFLICT
--and fall back if there is a unique constraint violation.
EXECUTE FORMAT(
'INSERT INTO prom_data.%1$I (time, value, series_id)
SELECT * FROM unnest($1, $2, $3) a(t,v,s) ORDER BY s,t',
metric_table
) USING time_array, value_array, series_id_array;
GET DIAGNOSTICS num_rows = ROW_COUNT;
RETURN num_rows;
EXCEPTION WHEN unique_violation THEN
EXECUTE FORMAT(
'INSERT INTO prom_data.%1$I (time, value, series_id)
SELECT * FROM unnest($1, $2, $3) a(t,v,s) ORDER BY s,t ON CONFLICT DO NOTHING',
metric_table
) USING time_array, value_array, series_id_array;
GET DIAGNOSTICS num_rows = ROW_COUNT;
RETURN num_rows;
END;
$$
LANGUAGE PLPGSQL;
GRANT EXECUTE ON FUNCTION _prom_catalog.insert_metric_row(NAME, TIMESTAMPTZ[], DOUBLE PRECISION[], BIGINT[]) TO prom_writer;
|
/* RUN TYPE DEFINITIONS */
/* THIS IS THE MASTER COND2CONF TABLE */
CREATE TABLE COND2CONF_TYPE_DEF (
DEF_ID NUMBER(2) NOT NULL,
REC_TYPE VARCHAR2(20)
);
ALTER TABLE cond2conf_type_def ADD CONSTRAINT COND2CONF_TYPE_DEF_PK PRIMARY KEY (DEF_ID);
INSERT INTO COND2CONF_TYPE_DEF(DEF_ID, REC_TYPE) VALUES( '0', 'PEDESTAL_OFFSETS' );
INSERT INTO COND2CONF_TYPE_DEF(DEF_ID, REC_TYPE) VALUES( '1', 'DELAY_OFFSETS' );
INSERT INTO COND2CONF_TYPE_DEF(DEF_ID, REC_TYPE) VALUES( '2', 'DCC_WEIGHTS' );
INSERT INTO COND2CONF_TYPE_DEF(DEF_ID, REC_TYPE) VALUES( '3', 'BAD_CRYSTALS' );
INSERT INTO COND2CONF_TYPE_DEF(DEF_ID, REC_TYPE) VALUES( '4', 'BAD_TT' );
CREATE TABLE COND2CONF_INFO (
REC_ID NUMBER(10) NOT NULL,
REC_TYPE_ID NUMBER(10) ,
REC_date DATE ,
LOCATION_ID NUMBER(10),
RUN_NUMBER NUMBER(10),
short_desc VARCHAR2(100),
db_timestamp TIMESTAMP DEFAULT SYSTIMESTAMP NOT NULL
);
ALTER TABLE cond2conf_info ADD CONSTRAINT COND2CONF_INFO_pk PRIMARY KEY (REC_ID);
ALTER TABLE COND2CONF_INFO ADD CONSTRAINT COND2CONF_INFO_FK FOREIGN KEY (REC_TYPE_ID) REFERENCES COND2CONF_TYPE_DEF(DEF_ID);
CREATE SEQUENCE COND2CONF_INFO_SQ INCREMENT BY 1 START WITH 1;
/* PEDESTAL OFFSETS */
CREATE TABLE pedestal_offsets_info (
rec_id NUMBER(10) NOT NULL,
TAG VARCHAR2(100),
version NUMBER(10),
db_timestamp TIMESTAMP DEFAULT SYSTIMESTAMP NOT NULL
);
ALTER TABLE pedestal_offsets_INFO ADD CONSTRAINT pedestal_offsets_INFO_PK PRIMARY KEY (rec_id);
ALTER TABLE pedestal_offsets_INFO ADD CONSTRAINT pedestal_offsets_INFO_uk UNIQUE(tag,version);
CREATE TABLE pedestal_offsets_dat (
REC_id NUMBER(10) NOT NULL,
sm_id NUMBER(10),
fed_id NUMBER(10),
tt_id NUMBER(10),
cry_id NUMBER(10),
low NUMBER,
mid NUMBER,
high NUMBER
);
ALTER TABLE PEDESTAL_OFFSETS_DAT ADD CONSTRAINT PEDESTAL_OFFSETS_DAT_FK FOREIGN KEY (REC_ID) REFERENCES COND2CONF_INFO (REC_ID);
ALTER TABLE PEDESTAL_OFFSETS_DAT ADD CONSTRAINT PEDESTAL_OFFSETS_DAT_pk PRIMARY KEY (rec_id, sm_id,tt_id, cry_id );
/* THIS IS FOR THE DELAYS */
CREATE TABLE DELAYS_info (
rec_id NUMBER(10) NOT NULL,
TAG VARCHAR2(100),
version NUMBER(10),
db_timestamp TIMESTAMP DEFAULT SYSTIMESTAMP NOT NULL
);
ALTER TABLE delays_INFO ADD CONSTRAINT delays_INFO_PK PRIMARY KEY (rec_id);
ALTER TABLE delays_INFO ADD CONSTRAINT delays_INFO_uk UNIQUE(tag,version);
CREATE TABLE DELAYS_DAT (
REC_ID NUMBER(10) NOT NULL,
SM_ID NUMBER(10),
FED_ID NUMBER(10),
TT_ID NUMBER(10),
TIME_OFFSET NUMBER
);
ALTER TABLE DELAYS_DAT ADD CONSTRAINT DELAYS_DAT_FK FOREIGN KEY (REC_ID) REFERENCES COND2CONF_INFO (REC_ID);
ALTER TABLE DELAYS_DAT ADD CONSTRAINT DELAYS_DAT_pk PRIMARY KEY (rec_id, sm_id,tt_id);
/* THIS IS FOR THE WEIGHTS */
/* THIS IS FOR THE WEIGHTS */
CREATE TABLE dcc_weights_info (
rec_id NUMBER(10) NOT NULL,
TAG VARCHAR2(100),
version NUMBER(10),
db_timestamp TIMESTAMP DEFAULT SYSTIMESTAMP NOT NULL
);
ALTER TABLE dcc_weights_INFO ADD CONSTRAINT dcc_weights_INFO_PK PRIMARY KEY (rec_id);
ALTER TABLE dcc_weights_INFO ADD CONSTRAINT dcc_weights_INFO_uk UNIQUE(tag,version);
CREATE TABLE DCC_WEIGHTS_DAT (
REC_ID NUMBER(10) NOT NULL,
SM_ID NUMBER(10),
FED_ID NUMBER(10),
TT_ID NUMBER(10),
CRY_ID NUMBER(10),
WEI0 NUMBER,
WEI1 NUMBER,
WEI2 NUMBER,
WEI3 NUMBER,
WEI4 NUMBER,
WEI5 NUMBER
);
ALTER TABLE DCC_WEIGHTS_DAT ADD CONSTRAINT DCC_WEIGHTS_DAT_FK FOREIGN KEY (REC_ID) REFERENCES COND2CONF_INFO (REC_ID);
ALTER TABLE DCC_WEIGHTS_DAT ADD CONSTRAINT DCC_WEIGHTS_DAT_pk PRIMARY KEY (rec_id, sm_id,tt_id, cry_id );
CREATE TABLE DCC_WEIGHTSAMPLE_DAT (
REC_ID NUMBER(10) NOT NULL,
FED_ID NUMBER(10),
sample_id NUMBER(2),
weight_number NUMBER(1)
);
ALTER TABLE DCC_WEIGHTSAMPLE_DAT ADD CONSTRAINT DCC_WEIGHTSAMPLE_DAT_pk PRIMARY KEY (rec_id, fed_id, sample_id );
ALTER TABLE DCC_WEIGHTSAMPLE_DAT ADD CONSTRAINT DCC_WEIGHTSAMPLE_DAT_FK FOREIGN KEY (REC_ID) REFERENCES COND2CONF_INFO (REC_
ID);
create OR REPLACE TRIGGER cond2conf_auto_tg3
BEFORE INSERT ON dcc_weights_info
REFERENCING NEW AS newiov
FOR EACH ROW
CALL cond2conf_autoinsert('DCC_WEIGHTS', :newiov.rec_id, :newiov.tag, :newiov.version)
/
/* CRYSTAL bad channels */
CREATE TABLE BAD_Crystals_info (
rec_id NUMBER(10) NOT NULL,
TAG VARCHAR2(100),
version NUMBER(10),
db_timestamp TIMESTAMP DEFAULT SYSTIMESTAMP NOT NULL
);
ALTER TABLE bad_crystals_INFO ADD CONSTRAINT bad_crystals_INFO_PK PRIMARY KEY (rec_id);
ALTER TABLE bad_crystals_INFO ADD CONSTRAINT bad_crystals_INFO_uk UNIQUE(tag,version);
CREATE TABLE bad_crystals_dat (
REC_id NUMBER(10) NOT NULL,
sm_id NUMBER(10),
fed_id NUMBER(10),
tt_id NUMBER(10),
cry_id NUMBER(10),
status NUMBER
);
ALTER TABLE bad_crystals_DAT ADD CONSTRAINT bad_crystals_DAT_FK FOREIGN KEY (REC_ID) REFERENCES COND2CONF_INFO (REC_ID);
ALTER TABLE bad_crystals_DAT ADD CONSTRAINT bad_crystals_DAT_pk PRIMARY KEY (rec_id, sm_id,tt_id, cry_id );
/* TT bad channels */
CREATE TABLE BAD_TT_info (
rec_id NUMBER(10) NOT NULL,
TAG VARCHAR2(100),
version NUMBER(10),
db_timestamp TIMESTAMP DEFAULT SYSTIMESTAMP NOT NULL
);
ALTER TABLE bad_tt_INFO ADD CONSTRAINT bad_tt_INFO_PK PRIMARY KEY (rec_id);
ALTER TABLE bad_tt_INFO ADD CONSTRAINT bad_tt_INFO_uk UNIQUE(tag,version);
CREATE TABLE bad_tt_dat (
REC_id NUMBER(10) NOT NULL,
sm_id NUMBER(10),
fed_id NUMBER(10),
tt_id NUMBER(10),
status NUMBER
);
ALTER TABLE bad_tt_DAT ADD CONSTRAINT bad_tt_DAT_FK FOREIGN KEY (REC_ID) REFERENCES COND2CONF_INFO (REC_ID);
ALTER TABLE bad_tt_DAT ADD CONSTRAINT bad_tt_DAT_pk PRIMARY KEY (rec_id, sm_id,tt_id );
/* towers to bypass */
CREATE TABLE TOWERS_TO_BYPASS_INFO (
rec_id NUMBER(10) NOT NULL,
TAG VARCHAR2(100),
version NUMBER(10),
db_timestamp TIMESTAMP DEFAULT SYSTIMESTAMP NOT NULL
);
ALTER TABLE TOWERS_TO_BYPASS_INFO ADD CONSTRAINT TOWERS_TO_BYPASS_INFO_PK PRIMARY KEY (rec_id);
ALTER TABLE TOWERS_TO_BYPASS_INFO ADD CONSTRAINT TOWERS_TO_BYPASS_INFO_uk UNIQUE(tag,version);
CREATE TABLE TOWERS_TO_BYPASS_dat (
REC_id NUMBER(10) NOT NULL,
fed_id NUMBER(3) not null,
tr_id NUMBER(3) not null,
tt_id NUMBER(3) not null,
time_corr NUMBER(10),
status NUMBER(10)
);
ALTER TABLE TOWERS_TO_BYPASS_DAT ADD CONSTRAINT TOWERS_TO_BYPASS_DAT_pk PRIMARY KEY (rec_id, fed_id, tr_id, tt_id );
/* vfes to reject */
CREATE TABLE VFES_TO_REJECT_INFO (
rec_id NUMBER(10) NOT NULL,
TAG VARCHAR2(100),
version NUMBER(10),
db_timestamp TIMESTAMP DEFAULT SYSTIMESTAMP NOT NULL
);
ALTER TABLE VFES_TO_REJECT_INFO ADD CONSTRAINT VFES_TO_REJECT_INFO_PK PRIMARY KEY (rec_id);
ALTER TABLE VFES_TO_REJECT_INFO ADD CONSTRAINT VFES_TO_REJECT_INFO_uk UNIQUE(tag,version);
CREATE TABLE VFES_TO_REJECT_dat (
REC_id NUMBER(10) NOT NULL,
fed_id NUMBER(3) not null,
tt_id NUMBER(3) not null,
vfe_id NUMBER(3) not null,
gain NUMBER(10),
status NUMBER(10)
);
ALTER TABLE VFES_TO_REJECT_DAT ADD CONSTRAINT VFES_TO_REJECT_DAT_pk PRIMARY KEY (rec_id, fed_id, tt_id, vfe_id );
/* GOL bias current */
CREATE TABLE GOL_BIAS_CURRENT_INFO (
rec_id NUMBER(10) NOT NULL,
TAG VARCHAR2(100),
version NUMBER(10),
db_timestamp TIMESTAMP DEFAULT SYSTIMESTAMP NOT NULL
);
ALTER TABLE GOL_BIAS_CURRENT_INFO ADD CONSTRAINT GOL_BIAS_CURRENT_INFO_PK PRIMARY KEY (rec_id);
ALTER TABLE GOL_BIAS_CURRENT_INFO ADD CONSTRAINT GOL_BIAS_CURRENT_INFO_uk UNIQUE(tag,version);
CREATE TABLE GOL_BIAS_CURRENT_DAT (
REC_id NUMBER(10) NOT NULL,
fed_id NUMBER(3) not null,
tt_id NUMBER(3) not null,
gol_id NUMBER(2) not null,
gol_current NUMBER(10),
pll_current NUMBER(10),
status NUMBER(10)
);
ALTER TABLE GOL_BIAS_CURRENT_DAT ADD CONSTRAINT GOL_BIAS_CURRENT_DAT_pk PRIMARY KEY (rec_id, fed_id, tt_id, gol_id );
/* FE DAQ */
CREATE TABLE FE_DAQ_CONFIG (
config_id NUMBER(10) NOT NULL,
tag VARCHAR2(20) not null,
version NUMBER(10) not null,
ped_id NUMBER(10),
del_id NUMBER(10),
wei_id NUMBER(10),
bxt_id NUMBER(10),
btt_id NUMBER(10),
TR_BXT_ID NUMBER(10),
TR_BTT_ID NUMBER(10),
TBY_ID NUMBER(10),
VFE_ID NUMBER(10),
GOL_ID NUMBER(10),
USER_COMMENT VARCHAR2(100),
db_timestamp TIMESTAMP DEFAULT SYSTIMESTAMP NOT NULL
);
ALTER TABLE FE_DAQ_CONFIG ADD CONSTRAINT FE_DAQ_CONFIG_pk PRIMARY KEY (config_id);
ALTER TABLE FE_DAQ_CONFIG ADD CONSTRAINT FE_DAQ_CONFIG_uk UNIQUE(tag,version);
ALTER TABLE FE_DAQ_CONFIG ADD CONSTRAINT FE_DAQ_CONFIG_fk1 FOREIGN KEY (ped_ID) REFERENCES COND2CONF_INFO (REC_ID);
ALTER TABLE FE_DAQ_CONFIG ADD CONSTRAINT FE_DAQ_CONFIG_fk2 FOREIGN KEY (del_ID) REFERENCES COND2CONF_INFO (REC_ID);
ALTER TABLE FE_DAQ_CONFIG ADD CONSTRAINT FE_DAQ_CONFIG_fk3 FOREIGN KEY (wei_ID) REFERENCES COND2CONF_INFO (REC_ID);
CREATE SEQUENCE FE_DAQ_CONDFIG_SQ INCREMENT BY 1 START WITH 1;
---- Some mapping tables
create table ECAL_FED_DEF(
DEF_ID NUMBER NOT NULL,
HOST VARCHAR2(100) NOT NULL,
SLOT NUMBER NOT NULL,
BOARD_ID NUMBER,
FED_ID NUMBER NOT NULL
);
-- DOESN'T WORK FOR PRESHOWER
ALTER TABLE ECAL_FED_DEF ADD CONSTRAINT ecal_fed_def_pk PRIMARY KEY (DEF_ID);
-- ALTER TABLE ECAL_FED_DEF ADD CONSTRAINT ecal_fed_def_uk UNIQUE (host,slot);
-- NOT USED ANYMORE
CREATE SEQUENCE ecal_fed_def_sq INCREMENT BY 1 START WITH 1;
CREATE trigger ecal_fed_def_trg
before insert on ECAL_FED_DEF
for each row
begin
select ecal_fed_def_sq.NextVal into :new.def_id from dual;
end;
/
create table ECAL_FED_TO_SUPERMODULE(
DEF_ID NUMBER NOT NULL,
FED_ID NUMBER NOT NULL,
CONSTR_ID NUMBER NOT NULL,
PSEUDO_SLOT_ID NUMBER NOT NULL,
GEOM_ID VARCHAR(10)
);
ALTER TABLE ECAL_FED_TO_SUPERMODULE ADD CONSTRAINT ECAL_FED_TO_SUPERMODULE_PK PRIMARY KEY (DEF_ID);
ALTER TABLE ECAL_FED_TO_SUPERMODULE ADD CONSTRAINT ECAL_FED_TO_SUPERMODULE_UK1 UNIQUE (FED_ID);
ALTER TABLE ECAL_FED_TO_SUPERMODULE ADD CONSTRAINT ECAL_FED_TO_SUPERMODULE_UK2 UNIQUE (CONSTR_ID);
ALTER TABLE ECAL_FED_TO_SUPERMODULE ADD CONSTRAINT ECAL_FED_TO_SUPERMODULE_UK3 UNIQUE (PSEUDO_SLOT_ID);
CREATE SEQUENCE ECAL_FED_TO_SUPERMODULE_SQ INCREMENT BY 1 START WITH 1;
CREATE trigger ECAL_FED_TO_SUPERMODULE_TRG
before insert on ECAL_FED_TO_SUPERMODULE
for each row
begin
select ECAL_FED_TO_SUPERMODULE_SQ.NextVal into :new.def_id from dual;
end;
/
CREATE OR REPLACE procedure cond2conf_autoinsert
(rec_type in varchar2, rec_id in NUMBER, tag in varchar2, version in number)
IS
sql_str VARCHAR(1000);
location_id number(10);
type_id number;
loca varchar2(10);
short_descr varchar2(30) ;
BEGIN
sql_str := 'SELECT def_id from cond2conf_type_def where rec_type=:1 ';
EXECUTE IMMEDIATE sql_str INTO type_id using rec_type ;
loca:='P5';
sql_str := 'SELECT def_id from location_def where location=:1 ';
EXECUTE IMMEDIATE sql_str INTO location_id using loca ;
short_descr:= tag || '_' || cast (version as varchar2) ;
sql_str :='Insert into COND2CONF_INFO (rec_id,REC_TYPE_ID, LOCATION_ID, short_desc ) values (:1, :2, :3, :4) ';
EXECUTE IMMEDIATE sql_str using rec_id, type_id, location_id, short_descr ;
end;
/
show errors;
create OR REPLACE TRIGGER cond2conf_auto_tg
BEFORE INSERT ON delays_info
REFERENCING NEW AS newiov
FOR EACH ROW
CALL cond2conf_autoinsert('DELAY_OFFSETS', :newiov.rec_id, :newiov.tag, :newiov.version)
/
create OR REPLACE TRIGGER cond2conf_auto2_tg
BEFORE INSERT ON pedestal_offsets_info
REFERENCING NEW AS newiov
FOR EACH ROW
CALL cond2conf_autoinsert('PEDESTAL_OFFSETS', :newiov.rec_id, :newiov.tag, :newiov.version)
/
create OR REPLACE TRIGGER cond2conf_auto_tg3
BEFORE INSERT ON weights_info
REFERENCING NEW AS newiov
FOR EACH ROW
CALL cond2conf_autoinsert('DCC_WEIGHTS', :newiov.rec_id, :newiov.tag, :newiov.version)
/
create OR REPLACE TRIGGER cond2conf_auto_tg4
BEFORE INSERT ON bad_crystals_info
REFERENCING NEW AS newiov
FOR EACH ROW
CALL cond2conf_autoinsert('BAD_CRYSTALS', :newiov.rec_id, :newiov.tag, :newiov.version)
/
create OR REPLACE TRIGGER cond2conf_auto_tg5
BEFORE INSERT ON bad_tt_info
REFERENCING NEW AS newiov
FOR EACH ROW
CALL cond2conf_autoinsert('BAD_TT', :newiov.rec_id, :newiov.tag, :newiov.version)
/
|
CREATE VIEW public.v6 AS
SELECT v2.c1,
v2.c2,
t1.c6
FROM public.v2,
public.t1;
ALTER TABLE public.v6 OWNER TO galiev_mr; |
<filename>migrations/1622293215-gen_validator_v1.sql
-- migrations/1614027314-gen_validator_v1.sql
-- :up
ALTER TYPE transaction_type ADD VALUE IF NOT EXISTS 'gen_validator_v1';
|
SELECT a FROM (SELECT 1 AS a, 2 AS b);
SELECT a FROM (SELECT 1 AS a, arrayJoin([2, 3]) AS b);
SELECT a FROM (SELECT 1 AS a, arrayJoin([2, 3]), arrayJoin([2, 3]));
SELECT a FROM (SELECT 1 AS a, arrayJoin([2, 3]), arrayJoin([4, 5]));
SELECT a, b FROM (SELECT a, * FROM (SELECT 1 AS a, 2 AS b, 3 AS c));
SELECT a, b FROM (SELECT a, *, arrayJoin(c) FROM (SELECT 1 AS a, 2 AS b, [3, 4] AS c));
|
<filename>cadsrapi/software/freestyle-search/software/freestylesearch/db/db-upgrade/oracle/clean_index_tables.sql
/*L
Copyright ScenPro Inc, SAIC-F
Distributed under the OSI-approved BSD 3-Clause License.
See http://ncip.github.com/cadsr-freestyle-search/LICENSE.txt for details.
L*/
/* Copyright ScenPro, Inc, 2006
$Header: /share/content/gforge/freestylesearch/freestylesearch/db-sql/clean_index_tables.sql,v 1.1 2007-12-11 22:21:02 hebell Exp $
$Name: not supported by cvs2svn $
Author: <NAME>
This script cleans the freestyle index tables in preparation of a complete reload. Perform the following steps:
1. Run this script.
2. Execute the Seed script.
Users may continue to use the API and Browser interface. The software will not break during this process, however,
the search results will not be guaranteed correct until the Seed script completes.
*/
begin sbrext.freestyle_pkg.truncate_gs_tables; end;
commit;
select count(*) from sbrext.gs_composite;
select count(*) from sbrext.gs_tokens;
|
<reponame>Yanci0/openGauss-server
DROP FUNCTION IF EXISTS pg_catalog.get_synchronised_standby_ip() CASCADE;
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 1234;
CREATE FUNCTION pg_catalog.get_synchronised_standby_ip(OUT standby_ip text) RETURNS text LANGUAGE INTERNAL STABLE as 'get_synchronised_standby_ip';
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 0;
|
-- MySQL dump 10.16 Distrib 10.3.9-MariaDB, for Win64 (AMD64)
--
-- Host: 192.168.99.100 Database: carcare
-- ------------------------------------------------------
-- Server version 10.3.10-MariaDB-1:10.3.10+maria~bionic
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!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 */;
--
-- Table structure for table `DATABASECHANGELOG`
--
DROP TABLE IF EXISTS `DATABASECHANGELOG`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `DATABASECHANGELOG` (
`ID` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`AUTHOR` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`FILENAME` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`DATEEXECUTED` datetime NOT NULL,
`ORDEREXECUTED` int(11) NOT NULL,
`EXECTYPE` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
`MD5SUM` varchar(35) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`DESCRIPTION` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`COMMENTS` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`TAG` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`LIQUIBASE` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`CONTEXTS` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`LABELS` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`DEPLOYMENT_ID` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `DATABASECHANGELOG`
--
LOCK TABLES `DATABASECHANGELOG` WRITE;
/*!40000 ALTER TABLE `DATABASECHANGELOG` DISABLE KEYS */;
INSERT INTO `DATABASECHANGELOG` VALUES ('00000000000001','jhipster','config/liquibase/changelog/00000000000000_initial_schema.xml','2019-01-10 20:13:20',1,'EXECUTED','7:4afb46bcf498cc2fd904f4b91e294183','createTable tableName=jhi_user; createTable tableName=jhi_authority; createTable tableName=jhi_user_authority; addPrimaryKey tableName=jhi_user_authority; addForeignKeyConstraint baseTableName=jhi_user_authority, constraintName=fk_authority_name, ...','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-1','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:20',2,'EXECUTED','7:0e71d48bd5c1a2d0a8c558849905ab92','createTable tableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-2','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:20',3,'EXECUTED','7:c588cb77afd71212890df5bac640ddbb','createTable tableName=inspections','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-3','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:20',4,'EXECUTED','7:2ecbf8c8b7906544292d056b1f36cf0f','createTable tableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-4','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:20',5,'EXECUTED','7:fa643e65ab8b84ca6f60ff09d4ffc720','createTable tableName=insurances','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-5','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:20',6,'EXECUTED','7:8f2710ce3ed6393e3059d8f88cca619f','createTable tableName=refuels','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-6','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:20',7,'EXECUTED','7:55cd432dfaf71968dcd860251d68e025','createTable tableName=repairs','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-7','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:20',8,'EXECUTED','7:a05e831ab2580bb8849cb2d6b410abf9','createTable tableName=routine_services','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-8','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:20',9,'EXECUTED','7:8977f1ca3eeef333a8e857eece10b1af','createTable tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-9','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:20',10,'EXECUTED','7:6dd2437b98a11c699d257afaae1466d5','addUniqueConstraint constraintName=UC_FUEL_TYPESTYPE_COL, tableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-10','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:20',11,'EXECUTED','7:88ea0d984fa8ff105fca78a0f0d57eeb','addUniqueConstraint constraintName=UC_INSPECTIONSUUID_COL, tableName=inspections','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-11','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:20',12,'EXECUTED','7:f224ca56194224a6984d694d2156119a','addUniqueConstraint constraintName=UC_INSURANCESUUID_COL, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-12','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:20',13,'EXECUTED','7:8f1c3e288280bc6e78cbc8e0b8814395','addUniqueConstraint constraintName=UC_INSURANCE_TYPESTYPE_COL, tableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-13','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:20',14,'EXECUTED','7:e29e09392a0e71142ab1b7626c6dcd80','addUniqueConstraint constraintName=UC_REFUELSUUID_COL, tableName=refuels','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-14','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:21',15,'EXECUTED','7:3f91951577520638364b7995b445c30e','addUniqueConstraint constraintName=UC_REPAIRSUUID_COL, tableName=repairs','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-15','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:21',16,'EXECUTED','7:c0dbeb534b4307adcfe500624644706d','addUniqueConstraint constraintName=UC_ROUTINE_SERVICESUUID_COL, tableName=routine_services','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-16','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:21',17,'EXECUTED','7:5da87e5df11fd3a30bbd2d1c5ee851a1','addUniqueConstraint constraintName=UC_VEHICLESUUID_COL, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-17','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:21',18,'EXECUTED','7:ffbf46241d987fb85d2c5de6a40015f8','addForeignKeyConstraint baseTableName=insurances, constraintName=FK24ys5lgfug2q78d310u04tylf, referencedTableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-18','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:21',19,'EXECUTED','7:9ac0a3097cebe9b60ea99c3b462f8df2','addForeignKeyConstraint baseTableName=refuels, constraintName=FK7cs5c7iw40lj73yo6s77u7rvl, referencedTableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-19','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:21',20,'EXECUTED','7:2698a528e9e36f15fccb9a8dc8752dbd','addForeignKeyConstraint baseTableName=vehicles, constraintName=FKck94koff5phplxnts3lahjinu, referencedTableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-20','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:21',21,'EXECUTED','7:e8e9d186a4cabf0e7a9539a84511beee','addForeignKeyConstraint baseTableName=vehicles, constraintName=FKhm05kh6d8f082pgddom1q1yco, referencedTableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-21','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:21',22,'EXECUTED','7:61e53ba053e945e0f9110f3378ba6392','addForeignKeyConstraint baseTableName=insurances, constraintName=FKk7a7uqrkf4cuvn4w2rsdymafk, referencedTableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-22','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:21',23,'EXECUTED','7:46a91b16a3d957a37a8a5eb828fed957','addForeignKeyConstraint baseTableName=inspections, constraintName=FKlfc8sgfw636xmcre6gj9ra4pe, referencedTableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-23','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:21',24,'EXECUTED','7:de3d91fa0fca4a49ec45b412e389f2e3','addForeignKeyConstraint baseTableName=repairs, constraintName=FKr8rwhlbv43kxbn4j93hkul7ax, referencedTableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-24','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:21',25,'EXECUTED','7:58fe241f8a1fcb322de5488faa5b128a','addForeignKeyConstraint baseTableName=routine_services, constraintName=FKsy0jrbbtf29lpv37ahmtlj3dv, referencedTableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-25','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:21',26,'EXECUTED','7:4fbb584535e451702de5411972a56530','dropDefaultValue columnName=activation_key, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-26','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:21',27,'EXECUTED','7:8cc1d59098fc2e24219908855713317c','dropDefaultValue columnName=email, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-27','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:22',28,'EXECUTED','7:de9c1cfe5b771e385742658192bf10a3','dropDefaultValue columnName=event_type, tableName=jhi_persistent_audit_event','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-28','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:22',29,'EXECUTED','7:4890df99882170149a47f36c80f4ce38','dropDefaultValue columnName=first_name, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-29','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:22',30,'EXECUTED','7:75319e33742eeef13b01c6c156425275','dropDefaultValue columnName=image_url, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-30','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:22',31,'EXECUTED','7:83e98119c120277c7e17fe3470a8bf8e','dropDefaultValue columnName=lang_key, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-31','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:22',32,'EXECUTED','7:323f3047873d9c5b284de40b5881bb89','dropDefaultValue columnName=last_modified_by, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-32','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:22',33,'EXECUTED','7:aa0afacab9b39e122c2605ee39dddbb4','dropDefaultValue columnName=last_name, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-33','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:22',34,'EXECUTED','7:13e9c7c3cf6fa9168cf0d109def4409f','dropDefaultValue columnName=reset_key, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545061695176-34','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-10 20:13:22',35,'EXECUTED','7:4d2c9e85eeecef4b597611537c9fad13','dropDefaultValue columnName=value, tableName=jhi_persistent_audit_evt_data','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-1','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',36,'EXECUTED','7:800ef3269aa70d9b1394dd93a39f8370','dropUniqueConstraint constraintName=UC_INSPECTIONSUUID_COL, tableName=inspections','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-2','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',37,'EXECUTED','7:9ac30e74165c99a233a8d7446a004aac','dropUniqueConstraint constraintName=UC_INSURANCESUUID_COL, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-3','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',38,'EXECUTED','7:f883641bc8db829dba3932665e63e1ac','dropUniqueConstraint constraintName=UC_REFUELSUUID_COL, tableName=refuels','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-4','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',39,'EXECUTED','7:8ef3059ac7d8d2370c69d3d4e91dd9a1','dropUniqueConstraint constraintName=UC_REPAIRSUUID_COL, tableName=repairs','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-5','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',40,'EXECUTED','7:e093094a000bdd8e771c3e616882fb1e','dropUniqueConstraint constraintName=UC_ROUTINE_SERVICESUUID_COL, tableName=routine_services','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-6','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',41,'EXECUTED','7:5811915c21d3e79c189093e79fc526ae','dropUniqueConstraint constraintName=UC_VEHICLESUUID_COL, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-7','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',42,'EXECUTED','7:b5a8dfcb7f6b3eaffa40fcf433f36b0a','dropColumn columnName=uuid, tableName=inspections','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-8','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',43,'EXECUTED','7:7d3082e313a027b72a917233fb9bf09b','dropColumn columnName=uuid, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-9','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',44,'EXECUTED','7:6e16283710b8a5cbf6275ed0eaf9b04b','dropColumn columnName=uuid, tableName=refuels','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-10','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',45,'EXECUTED','7:243caaf0e0020f5eea16e319dcc94d9f','dropColumn columnName=uuid, tableName=repairs','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-11','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',46,'EXECUTED','7:40193f54468710b224d31b12cc867ebc','dropColumn columnName=uuid, tableName=routine_services','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-12','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',47,'EXECUTED','7:f5d7a123009cfdf5233c255eb26b1171','dropColumn columnName=uuid, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-13','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',48,'EXECUTED','7:ee35373fea60bedaa7b6011c224c02bf','dropDefaultValue columnName=details, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-14','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',49,'EXECUTED','7:06d91f24ac30f159188b9bd2acc4970d','dropDefaultValue columnName=image_content_type, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-15','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',50,'EXECUTED','7:d40ffe232dc7572a6f1f793ebd7ec306','dropDefaultValue columnName=insurer, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-16','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',51,'EXECUTED','7:2adef877c118340ec0e042351764de29','dropDefaultValue columnName=model_suffix, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-17','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',52,'EXECUTED','7:c56465ab52221a5ed0632be3211ed928','dropDefaultValue columnName=notes, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-18','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',53,'EXECUTED','7:0fff00b8125ed48ce215425546c10252','dropDefaultValue columnName=number, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-19','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',54,'EXECUTED','7:a3520b953370a6afd8f0dcd5b381e7fa','dropDefaultValue columnName=registration_certificate, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-20','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',55,'EXECUTED','7:73aa398d514e473e3e6b9a45a7c15d01','dropDefaultValue columnName=vehicle_card, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1545416098210-21','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-10 20:13:22',56,'EXECUTED','7:cd780528436784debfb10ed188458917','dropDefaultValue columnName=vin_number, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546467663093-1','Kacper (generated)','config/liquibase/changelog/20190102222057_changelog.xml','2019-01-10 20:13:22',57,'EXECUTED','7:8e3a7f149cd12b08ad51db5976b5ca14','addNotNullConstraint columnName=details, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546467663093-2','Kacper','config/liquibase/changelog/20190102222057_changelog.xml','2019-01-10 20:13:23',58,'EXECUTED','7:ce27a66a346667c5f06ed28afad11373','modifyDataType columnName=notes, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546467663093-3','Kacper','config/liquibase/changelog/20190102222057_changelog.xml','2019-01-10 20:13:23',59,'EXECUTED','7:63f5b0fbeb68a5ce35bce3267b0875db','modifyDataType columnName=details, tableName=inspections','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546467663093-4','Kacper','config/liquibase/changelog/20190102222057_changelog.xml','2019-01-10 20:13:23',60,'EXECUTED','7:657e87913e3cd37ec871935d471716d2','modifyDataType columnName=details, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546467663093-5','Kacper','config/liquibase/changelog/20190102222057_changelog.xml','2019-01-10 20:13:23',61,'EXECUTED','7:a3b4d1d4c402584c608f8f0cbc22f89b','modifyDataType columnName=details, tableName=repairs','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546467663093-6','Kacper','config/liquibase/changelog/20190102222057_changelog.xml','2019-01-10 20:13:23',62,'EXECUTED','7:e696d62b3a32e60f35f9d73ac6e2df20','modifyDataType columnName=details, tableName=routine_services','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546547935872-1','Kacper (generated)','config/liquibase/changelog/20190103203841_changelog.xml','2019-01-10 20:13:23',63,'EXECUTED','7:4f6a8f2f56680c0ec38cafb091a349c7','addNotNullConstraint columnName=details, tableName=inspections; dropDefaultValue columnName=details, tableName=inspections','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546547935872-2','Kacper (generated)','config/liquibase/changelog/20190103203841_changelog.xml','2019-01-10 20:13:23',64,'EXECUTED','7:ba30ecff44894234eb28c3ab9c543219','addNotNullConstraint columnName=details, tableName=insurances; dropDefaultValue columnName=details, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546547935872-3','Kacper (generated)','config/liquibase/changelog/20190103203841_changelog.xml','2019-01-10 20:13:23',65,'EXECUTED','7:4500dcf9402efc83380612e36dd954b1','addNotNullConstraint columnName=details, tableName=repairs; dropDefaultValue columnName=details, tableName=repairs','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546547935872-4','Kacper (generated)','config/liquibase/changelog/20190103203841_changelog.xml','2019-01-10 20:13:23',66,'EXECUTED','7:1265ba7ec438672dbd8991f0f2e42f1d','addNotNullConstraint columnName=details, tableName=routine_services; dropDefaultValue columnName=details, tableName=routine_services','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546547935872-5','Kacper (generated)','config/liquibase/changelog/20190103203841_changelog.xml','2019-01-10 20:13:23',67,'EXECUTED','7:e7fc087dbfde31990697a505a2a9a0ee','dropDefaultValue columnName=notes, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546548430063-1','Kacper (generated)','config/liquibase/changelog/20190103204656_changelog.xml','2019-01-10 20:13:23',68,'EXECUTED','7:daa93446a5a1b258aa76dd3a45509bfb','dropColumn columnName=image_content_type, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546875049766-1','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-10 20:13:23',69,'EXECUTED','7:bc8af992875eb1858a99f080f61aeb05','createTable tableName=reminder_advances','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546875049766-2','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-10 20:13:23',70,'EXECUTED','7:8cfcd06aa114ab5128bc66c4c791acad','addColumn tableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546875049766-3','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-10 20:13:23',71,'EXECUTED','7:48bd13e2b8fd8a9680a36a20380bc0d9','addColumn tableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546875049766-4','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-10 20:13:23',72,'EXECUTED','7:2aaae785d89367e5ba056cce61a1dfe4','addColumn tableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546875049766-5','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-10 20:13:23',73,'EXECUTED','7:2fd9e8fb62848ee538323c88b8d27e4e','addColumn tableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546875049766-6','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-10 20:13:24',74,'EXECUTED','7:514d91695bc49200c3f049d0481037fb','addUniqueConstraint constraintName=UC_FUEL_TYPESENGLISH_COL, tableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546875049766-7','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-10 20:13:24',75,'EXECUTED','7:7ff8f3b2cca73bc052b9694ba2c0cb19','addUniqueConstraint constraintName=UC_FUEL_TYPESPOLISH_COL, tableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546875049766-8','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-10 20:13:24',76,'EXECUTED','7:2c8cf603670d2a69f5486a31bc989645','addUniqueConstraint constraintName=UC_INSURANCE_TYPESENGLISH_COL, tableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546875049766-9','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-10 20:13:24',77,'EXECUTED','7:9e8382d58b2afef514e4381dacead342','addUniqueConstraint constraintName=UC_INSURANCE_TYPESPOLISH_COL, tableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'7151196974'),('1546875049766-10','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-10 20:13:24',78,'EXECUTED','7:11909b25ad79c4ffbda5faf06ac6c57b','addUniqueConstraint constraintName=UC_REMINDER_ADVANCESTYPE_COL, tableName=reminder_advances','',NULL,'3.5.4',NULL,NULL,'7151196974');
/*!40000 ALTER TABLE `DATABASECHANGELOG` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `DATABASECHANGELOGLOCK`
--
DROP TABLE IF EXISTS `DATABASECHANGELOGLOCK`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `DATABASECHANGELOGLOCK` (
`ID` int(11) NOT NULL,
`LOCKED` bit(1) NOT NULL,
`LOCKGRANTED` datetime DEFAULT NULL,
`LOCKEDBY` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `DATABASECHANGELOGLOCK`
--
LOCK TABLES `DATABASECHANGELOGLOCK` WRITE;
/*!40000 ALTER TABLE `DATABASECHANGELOGLOCK` DISABLE KEYS */;
INSERT INTO `DATABASECHANGELOGLOCK` VALUES (1,'\0',NULL,NULL);
/*!40000 ALTER TABLE `DATABASECHANGELOGLOCK` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `databasechangelog`
--
DROP TABLE IF EXISTS `databasechangelog`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `databasechangelog` (
`ID` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`AUTHOR` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`FILENAME` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`DATEEXECUTED` datetime NOT NULL,
`ORDEREXECUTED` int(11) NOT NULL,
`EXECTYPE` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
`MD5SUM` varchar(35) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`DESCRIPTION` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`COMMENTS` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`TAG` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`LIQUIBASE` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`CONTEXTS` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`LABELS` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`DEPLOYMENT_ID` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `databasechangelog`
--
LOCK TABLES `databasechangelog` WRITE;
/*!40000 ALTER TABLE `databasechangelog` DISABLE KEYS */;
INSERT INTO `databasechangelog` VALUES ('00000000000001','jhipster','config/liquibase/changelog/00000000000000_initial_schema.xml','2019-01-09 00:13:48',1,'EXECUTED','7:4afb46bcf498cc2fd904f4b91e294183','createTable tableName=jhi_user; createTable tableName=jhi_authority; createTable tableName=jhi_user_authority; addPrimaryKey tableName=jhi_user_authority; addForeignKeyConstraint baseTableName=jhi_user_authority, constraintName=fk_authority_name, ...','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-1','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',2,'EXECUTED','7:0e71d48bd5c1a2d0a8c558849905ab92','createTable tableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-2','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',3,'EXECUTED','7:c588cb77afd71212890df5bac640ddbb','createTable tableName=inspections','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-3','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',4,'EXECUTED','7:2ecbf8c8b7906544292d056b1f36cf0f','createTable tableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-4','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',5,'EXECUTED','7:fa643e65ab8b84ca6f60ff09d4ffc720','createTable tableName=insurances','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-5','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',6,'EXECUTED','7:8f2710ce3ed6393e3059d8f88cca619f','createTable tableName=refuels','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-6','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',7,'EXECUTED','7:55cd432dfaf71968dcd860251d68e025','createTable tableName=repairs','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-7','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',8,'EXECUTED','7:a05e831ab2580bb8849cb2d6b410abf9','createTable tableName=routine_services','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-8','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',9,'EXECUTED','7:8977f1ca3eeef333a8e857eece10b1af','createTable tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-9','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',10,'EXECUTED','7:6dd2437b98a11c699d257afaae1466d5','addUniqueConstraint constraintName=UC_FUEL_TYPESTYPE_COL, tableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-10','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',11,'EXECUTED','7:88ea0d984fa8ff105fca78a0f0d57eeb','addUniqueConstraint constraintName=UC_INSPECTIONSUUID_COL, tableName=inspections','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-11','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',12,'EXECUTED','7:f224ca56194224a6984d694d2156119a','addUniqueConstraint constraintName=UC_INSURANCESUUID_COL, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-12','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',13,'EXECUTED','7:8f1c3e288280bc6e78cbc8e0b8814395','addUniqueConstraint constraintName=UC_INSURANCE_TYPESTYPE_COL, tableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-13','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',14,'EXECUTED','7:e29e09392a0e71142ab1b7626c6dcd80','addUniqueConstraint constraintName=UC_REFUELSUUID_COL, tableName=refuels','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-14','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',15,'EXECUTED','7:3f91951577520638364b7995b445c30e','addUniqueConstraint constraintName=UC_REPAIRSUUID_COL, tableName=repairs','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-15','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',16,'EXECUTED','7:c0dbeb534b4307adcfe500624644706d','addUniqueConstraint constraintName=UC_ROUTINE_SERVICESUUID_COL, tableName=routine_services','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-16','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',17,'EXECUTED','7:5da87e5df11fd3a30bbd2d1c5ee851a1','addUniqueConstraint constraintName=UC_VEHICLESUUID_COL, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-17','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',18,'EXECUTED','7:ffbf46241d987fb85d2c5de6a40015f8','addForeignKeyConstraint baseTableName=insurances, constraintName=FK24ys5lgfug2q78d310u04tylf, referencedTableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-18','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:48',19,'EXECUTED','7:9ac0a3097cebe9b60ea99c3b462f8df2','addForeignKeyConstraint baseTableName=refuels, constraintName=FK7cs5c7iw40lj73yo6s77u7rvl, referencedTableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-19','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',20,'EXECUTED','7:2698a528e9e36f15fccb9a8dc8752dbd','addForeignKeyConstraint baseTableName=vehicles, constraintName=FKck94koff5phplxnts3lahjinu, referencedTableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-20','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',21,'EXECUTED','7:e8e9d186a4cabf0e7a9539a84511beee','addForeignKeyConstraint baseTableName=vehicles, constraintName=FKhm05kh6d8f082pgddom1q1yco, referencedTableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-21','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',22,'EXECUTED','7:61e53ba053e945e0f9110f3378ba6392','addForeignKeyConstraint baseTableName=insurances, constraintName=FKk7a7uqrkf4cuvn4w2rsdymafk, referencedTableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-22','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',23,'EXECUTED','7:46a91b16a3d957a37a8a5eb828fed957','addForeignKeyConstraint baseTableName=inspections, constraintName=FKlfc8sgfw636xmcre6gj9ra4pe, referencedTableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-23','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',24,'EXECUTED','7:de3d91fa0fca4a49ec45b412e389f2e3','addForeignKeyConstraint baseTableName=repairs, constraintName=FKr8rwhlbv43kxbn4j93hkul7ax, referencedTableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-24','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',25,'EXECUTED','7:58fe241f8a1fcb322de5488faa5b128a','addForeignKeyConstraint baseTableName=routine_services, constraintName=FKsy0jrbbtf29lpv37ahmtlj3dv, referencedTableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-25','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',26,'EXECUTED','7:4fbb584535e451702de5411972a56530','dropDefaultValue columnName=activation_key, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-26','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',27,'EXECUTED','7:8cc1d59098fc2e24219908855713317c','dropDefaultValue columnName=email, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-27','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',28,'EXECUTED','7:de9c1cfe5b771e385742658192bf10a3','dropDefaultValue columnName=event_type, tableName=jhi_persistent_audit_event','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-28','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',29,'EXECUTED','7:4890df99882170149a47f36c80f4ce38','dropDefaultValue columnName=first_name, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-29','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',30,'EXECUTED','7:75319e33742eeef13b01c6c156425275','dropDefaultValue columnName=image_url, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-30','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',31,'EXECUTED','7:83e98119c120277c7e17fe3470a8bf8e','dropDefaultValue columnName=lang_key, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-31','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',32,'EXECUTED','7:323f3047873d9c5b284de40b5881bb89','dropDefaultValue columnName=last_modified_by, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-32','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',33,'EXECUTED','7:aa0afacab9b39e122c2605ee39dddbb4','dropDefaultValue columnName=last_name, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-33','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',34,'EXECUTED','7:13e9c7c3cf6fa9168cf0d109def4409f','dropDefaultValue columnName=reset_key, tableName=jhi_user','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545061695176-34','Kacper (generated)','config/liquibase/changelog/20181217154803_changelog.xml','2019-01-09 00:13:49',35,'EXECUTED','7:4d2c9e85eeecef4b597611537c9fad13','dropDefaultValue columnName=value, tableName=jhi_persistent_audit_evt_data','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-1','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',36,'EXECUTED','7:800ef3269aa70d9b1394dd93a39f8370','dropUniqueConstraint constraintName=UC_INSPECTIONSUUID_COL, tableName=inspections','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-2','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',37,'EXECUTED','7:9ac30e74165c99a233a8d7446a004aac','dropUniqueConstraint constraintName=UC_INSURANCESUUID_COL, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-3','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',38,'EXECUTED','7:f883641bc8db829dba3932665e63e1ac','dropUniqueConstraint constraintName=UC_REFUELSUUID_COL, tableName=refuels','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-4','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',39,'EXECUTED','7:8ef3059ac7d8d2370c69d3d4e91dd9a1','dropUniqueConstraint constraintName=UC_REPAIRSUUID_COL, tableName=repairs','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-5','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',40,'EXECUTED','7:e093094a000bdd8e771c3e616882fb1e','dropUniqueConstraint constraintName=UC_ROUTINE_SERVICESUUID_COL, tableName=routine_services','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-6','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',41,'EXECUTED','7:5811915c21d3e79c189093e79fc526ae','dropUniqueConstraint constraintName=UC_VEHICLESUUID_COL, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-7','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',42,'EXECUTED','7:b5a8dfcb7f6b3eaffa40fcf433f36b0a','dropColumn columnName=uuid, tableName=inspections','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-8','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',43,'EXECUTED','7:7d3082e313a027b72a917233fb9bf09b','dropColumn columnName=uuid, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-9','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',44,'EXECUTED','7:6e16283710b8a5cbf6275ed0eaf9b04b','dropColumn columnName=uuid, tableName=refuels','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-10','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',45,'EXECUTED','7:243caaf0e0020f5eea16e319dcc94d9f','dropColumn columnName=uuid, tableName=repairs','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-11','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',46,'EXECUTED','7:40193f54468710b224d31b12cc867ebc','dropColumn columnName=uuid, tableName=routine_services','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-12','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',47,'EXECUTED','7:f5d7a123009cfdf5233c255eb26b1171','dropColumn columnName=uuid, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-13','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',48,'EXECUTED','7:ee35373fea60bedaa7b6011c224c02bf','dropDefaultValue columnName=details, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-14','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',49,'EXECUTED','7:06d91f24ac30f159188b9bd2acc4970d','dropDefaultValue columnName=image_content_type, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-15','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',50,'EXECUTED','7:d40ffe232dc7572a6f1f793ebd7ec306','dropDefaultValue columnName=insurer, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-16','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',51,'EXECUTED','7:2adef877c118340ec0e042351764de29','dropDefaultValue columnName=model_suffix, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-17','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',52,'EXECUTED','7:c56465ab52221a5ed0632be3211ed928','dropDefaultValue columnName=notes, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-18','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',53,'EXECUTED','7:0fff00b8125ed48ce215425546c10252','dropDefaultValue columnName=number, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-19','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',54,'EXECUTED','7:a3520b953370a6afd8f0dcd5b381e7fa','dropDefaultValue columnName=registration_certificate, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-20','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',55,'EXECUTED','7:73aa398d514e473e3e6b9a45a7c15d01','dropDefaultValue columnName=vehicle_card, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1545416098210-21','Kacper (generated)','config/liquibase/changelog/20181221181442_changelog.xml','2019-01-09 00:13:49',56,'EXECUTED','7:cd780528436784debfb10ed188458917','dropDefaultValue columnName=vin_number, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546467663093-1','Kacper (generated)','config/liquibase/changelog/20190102222057_changelog.xml','2019-01-09 00:13:49',57,'EXECUTED','7:8e3a7f149cd12b08ad51db5976b5ca14','addNotNullConstraint columnName=details, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546467663093-2','Kacper','config/liquibase/changelog/20190102222057_changelog.xml','2019-01-09 00:13:49',58,'EXECUTED','7:ce27a66a346667c5f06ed28afad11373','modifyDataType columnName=notes, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546467663093-3','Kacper','config/liquibase/changelog/20190102222057_changelog.xml','2019-01-09 00:13:49',59,'EXECUTED','7:63f5b0fbeb68a5ce35bce3267b0875db','modifyDataType columnName=details, tableName=inspections','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546467663093-4','Kacper','config/liquibase/changelog/20190102222057_changelog.xml','2019-01-09 00:13:49',60,'EXECUTED','7:657e87913e3cd37ec871935d471716d2','modifyDataType columnName=details, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546467663093-5','Kacper','config/liquibase/changelog/20190102222057_changelog.xml','2019-01-09 00:13:49',61,'EXECUTED','7:a3b4d1d4c402584c608f8f0cbc22f89b','modifyDataType columnName=details, tableName=repairs','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546467663093-6','Kacper','config/liquibase/changelog/20190102222057_changelog.xml','2019-01-09 00:13:49',62,'EXECUTED','7:e696d62b3a32e60f35f9d73ac6e2df20','modifyDataType columnName=details, tableName=routine_services','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546547935872-1','Kacper (generated)','config/liquibase/changelog/20190103203841_changelog.xml','2019-01-09 00:13:49',63,'EXECUTED','7:4f6a8f2f56680c0ec38cafb091a349c7','addNotNullConstraint columnName=details, tableName=inspections; dropDefaultValue columnName=details, tableName=inspections','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546547935872-2','Kacper (generated)','config/liquibase/changelog/20190103203841_changelog.xml','2019-01-09 00:13:49',64,'EXECUTED','7:ba30ecff44894234eb28c3ab9c543219','addNotNullConstraint columnName=details, tableName=insurances; dropDefaultValue columnName=details, tableName=insurances','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546547935872-3','Kacper (generated)','config/liquibase/changelog/20190103203841_changelog.xml','2019-01-09 00:13:49',65,'EXECUTED','7:4500dcf9402efc83380612e36dd954b1','addNotNullConstraint columnName=details, tableName=repairs; dropDefaultValue columnName=details, tableName=repairs','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546547935872-4','Kacper (generated)','config/liquibase/changelog/20190103203841_changelog.xml','2019-01-09 00:13:49',66,'EXECUTED','7:1265ba7ec438672dbd8991f0f2e42f1d','addNotNullConstraint columnName=details, tableName=routine_services; dropDefaultValue columnName=details, tableName=routine_services','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546547935872-5','Kacper (generated)','config/liquibase/changelog/20190103203841_changelog.xml','2019-01-09 00:13:49',67,'EXECUTED','7:e7fc087dbfde31990697a505a2a9a0ee','dropDefaultValue columnName=notes, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546548430063-1','Kacper (generated)','config/liquibase/changelog/20190103204656_changelog.xml','2019-01-09 00:13:49',68,'EXECUTED','7:daa93446a5a1b258aa76dd3a45509bfb','dropColumn columnName=image_content_type, tableName=vehicles','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546875049766-1','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-09 00:13:49',69,'EXECUTED','7:bc8af992875eb1858a99f080f61aeb05','createTable tableName=reminder_advances','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546875049766-2','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-09 00:13:49',70,'EXECUTED','7:8cfcd06aa114ab5128bc66c4c791acad','addColumn tableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546875049766-3','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-09 00:13:49',71,'EXECUTED','7:48bd13e2b8fd8a9680a36a20380bc0d9','addColumn tableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546875049766-4','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-09 00:13:49',72,'EXECUTED','7:2aaae785d89367e5ba056cce61a1dfe4','addColumn tableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546875049766-5','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-09 00:13:49',73,'EXECUTED','7:2fd9e8fb62848ee538323c88b8d27e4e','addColumn tableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546875049766-6','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-09 00:13:49',74,'EXECUTED','7:514d91695bc49200c3f049d0481037fb','addUniqueConstraint constraintName=UC_FUEL_TYPESENGLISH_COL, tableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546875049766-7','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-09 00:13:49',75,'EXECUTED','7:7ff8f3b2cca73bc052b9694ba2c0cb19','addUniqueConstraint constraintName=UC_FUEL_TYPESPOLISH_COL, tableName=fuel_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546875049766-8','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-09 00:13:49',76,'EXECUTED','7:2c8cf603670d2a69f5486a31bc989645','addUniqueConstraint constraintName=UC_INSURANCE_TYPESENGLISH_COL, tableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546875049766-9','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-09 00:13:49',77,'EXECUTED','7:9e8382d58b2afef514e4381dacead342','addUniqueConstraint constraintName=UC_INSURANCE_TYPESPOLISH_COL, tableName=insurance_types','',NULL,'3.5.4',NULL,NULL,'6992828099'),('1546875049766-10','Kacper (generated)','config/liquibase/changelog/20190107153035_changelog.xml','2019-01-09 00:13:49',78,'EXECUTED','7:11909b25ad79c4ffbda5faf06ac6c57b','addUniqueConstraint constraintName=UC_REMINDER_ADVANCESTYPE_COL, tableName=reminder_advances','',NULL,'3.5.4',NULL,NULL,'6992828099');
/*!40000 ALTER TABLE `databasechangelog` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `databasechangeloglock`
--
DROP TABLE IF EXISTS `databasechangeloglock`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `databasechangeloglock` (
`ID` int(11) NOT NULL,
`LOCKED` bit(1) NOT NULL,
`LOCKGRANTED` datetime DEFAULT NULL,
`LOCKEDBY` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `databasechangeloglock`
--
LOCK TABLES `databasechangeloglock` WRITE;
/*!40000 ALTER TABLE `databasechangeloglock` DISABLE KEYS */;
INSERT INTO `databasechangeloglock` VALUES (1,'\0',NULL,NULL);
/*!40000 ALTER TABLE `databasechangeloglock` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `fuel_types`
--
DROP TABLE IF EXISTS `fuel_types`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `fuel_types` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`type` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`english` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`polish` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UC_FUEL_TYPESTYPE_COL` (`type`),
UNIQUE KEY `UC_FUEL_TYPESENGLISH_COL` (`english`),
UNIQUE KEY `UC_FUEL_TYPESPOLISH_COL` (`polish`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `fuel_types`
--
LOCK TABLES `fuel_types` WRITE;
/*!40000 ALTER TABLE `fuel_types` DISABLE KEYS */;
INSERT INTO `fuel_types` VALUES (1,'DIESEL','DIESEL','DIESEL'),(2,'PETROL','PETROL','BENZYNA'),(3,'LPG','LPG','LPG'),(4,'CNG','CNG','CNG'),(5,'HYBRID','HYBRID','HYBRYDOWY'),(6,'ELECTRIC','ELECTRIC','ELEKTRYCZNY'),(7,'OTHER','Other','Inny');
/*!40000 ALTER TABLE `fuel_types` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `inspections`
--
DROP TABLE IF EXISTS `inspections`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `inspections` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`cost_in_cents` int(11) NOT NULL,
`details` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`station` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`valid_thru` date NOT NULL,
`date` date NOT NULL,
`mileage` int(11) NOT NULL,
`vehicle_id` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `FKlfc8sgfw636xmcre6gj9ra4pe` (`vehicle_id`),
CONSTRAINT `FKlfc8sgfw636xmcre6gj9ra4pe` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicles` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `inspections`
--
LOCK TABLES `inspections` WRITE;
/*!40000 ALTER TABLE `inspections` DISABLE KEYS */;
INSERT INTO `inspections` VALUES (1,9700,'OK','AutoDiagnostic','2019-02-03','2018-02-03',100800,1),(2,9700,'OK','AutoDiagnostic','2018-02-03','2017-02-03',89700,1),(3,9700,'OK','DiagnoStation','2018-01-14','2017-01-15',180700,3),(4,9700,'OK','DiagnoPro','2019-01-14','2018-01-15',200700,3);
/*!40000 ALTER TABLE `inspections` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `insurance_types`
--
DROP TABLE IF EXISTS `insurance_types`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `insurance_types` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`type` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
`english` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`polish` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UC_INSURANCE_TYPESTYPE_COL` (`type`),
UNIQUE KEY `UC_INSURANCE_TYPESENGLISH_COL` (`english`),
UNIQUE KEY `UC_INSURANCE_TYPESPOLISH_COL` (`polish`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `insurance_types`
--
LOCK TABLES `insurance_types` WRITE;
/*!40000 ALTER TABLE `insurance_types` DISABLE KEYS */;
INSERT INTO `insurance_types` VALUES (1,'LI','LIABILITY INSURANCE','OC'),(2,'CC','COMPREHENSIVE COVER','AC'),(3,'OTHER','Other','Inne');
/*!40000 ALTER TABLE `insurance_types` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `insurances`
--
DROP TABLE IF EXISTS `insurances`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `insurances` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`cost_in_cents` int(11) NOT NULL,
`details` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`insurer` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`number` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`valid_from` date NOT NULL,
`valid_thru` date NOT NULL,
`date` date NOT NULL,
`mileage` int(11) NOT NULL,
`insurance_type_id` bigint(20) NOT NULL,
`vehicle_id` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK24ys5lgfug2q78d310u04tylf` (`insurance_type_id`),
KEY `FKk7a7uqrkf4cuvn4w2rsdymafk` (`vehicle_id`),
CONSTRAINT `FK24ys5lgfug2q78d310u04tylf` FOREIGN KEY (`insurance_type_id`) REFERENCES `insurance_types` (`id`),
CONSTRAINT `FKk7a7uqrkf4cuvn4w2rsdymafk` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicles` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `insurances`
--
LOCK TABLES `insurances` WRITE;
/*!40000 ALTER TABLE `insurances` DISABLE KEYS */;
INSERT INTO `insurances` VALUES (1,70000,'Z NNW','YourInsurance','XXX-YYY-ZZZ-2018','2018-02-02','2019-02-02','2018-01-16',100300,1,1),(2,75000,'','YourInsurance','YYY-XXX-ZZZ-2018','2018-02-02','2019-02-02','2018-01-16',100300,2,1),(3,68000,'','Insurer','ZZZ-XXX-AAA-2017','2017-02-02','2018-02-01','2017-01-20',90000,1,1),(4,90000,'','Insurances','ASDF-QWER-ZXC-2018','2017-02-20','2018-02-20','2017-02-14',180000,1,3),(5,95000,'Zawiera NNW','Insurances','ZXC-ASD-QWE-2018','2018-02-20','2019-02-20','2018-02-10',201600,1,3);
/*!40000 ALTER TABLE `insurances` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `jhi_authority`
--
DROP TABLE IF EXISTS `jhi_authority`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `jhi_authority` (
`name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `jhi_authority`
--
LOCK TABLES `jhi_authority` WRITE;
/*!40000 ALTER TABLE `jhi_authority` DISABLE KEYS */;
INSERT INTO `jhi_authority` VALUES ('ROLE_ADMIN'),('ROLE_USER');
/*!40000 ALTER TABLE `jhi_authority` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `jhi_persistent_audit_event`
--
DROP TABLE IF EXISTS `jhi_persistent_audit_event`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `jhi_persistent_audit_event` (
`event_id` bigint(20) NOT NULL AUTO_INCREMENT,
`principal` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`event_date` timestamp NULL DEFAULT NULL,
`event_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`event_id`),
KEY `idx_persistent_audit_event` (`principal`,`event_date`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `jhi_persistent_audit_event`
--
LOCK TABLES `jhi_persistent_audit_event` WRITE;
/*!40000 ALTER TABLE `jhi_persistent_audit_event` DISABLE KEYS */;
INSERT INTO `jhi_persistent_audit_event` VALUES (1,'testUser','2019-01-09 00:16:51','AUTHENTICATION_FAILURE'),(2,'testuser','2019-01-09 00:16:58','AUTHENTICATION_SUCCESS'),(3,'admin','2019-01-09 00:17:04','AUTHENTICATION_SUCCESS'),(4,'testuser','2019-01-09 00:23:20','AUTHENTICATION_SUCCESS'),(5,'testuser','2019-01-09 00:58:37','AUTHENTICATION_SUCCESS'),(6,'admin','2019-01-09 01:18:21','AUTHENTICATION_SUCCESS'),(7,'testuser','2019-01-09 01:18:29','AUTHENTICATION_SUCCESS'),(8,'userTest','2019-01-09 08:02:36','AUTHENTICATION_FAILURE'),(9,'testUser','2019-01-09 08:02:43','AUTHENTICATION_FAILURE'),(10,'testuser','2019-01-09 08:02:49','AUTHENTICATION_SUCCESS'),(11,'testuser','2019-01-09 09:22:55','AUTHENTICATION_SUCCESS'),(12,'testuser','2019-01-10 21:17:30','AUTHENTICATION_SUCCESS');
/*!40000 ALTER TABLE `jhi_persistent_audit_event` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `jhi_persistent_audit_evt_data`
--
DROP TABLE IF EXISTS `jhi_persistent_audit_evt_data`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `jhi_persistent_audit_evt_data` (
`event_id` bigint(20) NOT NULL,
`name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`value` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`event_id`,`name`),
KEY `idx_persistent_audit_evt_data` (`event_id`),
CONSTRAINT `fk_evt_pers_audit_evt_data` FOREIGN KEY (`event_id`) REFERENCES `jhi_persistent_audit_event` (`event_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `jhi_persistent_audit_evt_data`
--
LOCK TABLES `jhi_persistent_audit_evt_data` WRITE;
/*!40000 ALTER TABLE `jhi_persistent_audit_evt_data` DISABLE KEYS */;
INSERT INTO `jhi_persistent_audit_evt_data` VALUES (1,'message','Bad credentials'),(1,'type','org.springframework.security.authentication.BadCredentialsException'),(8,'message','Bad credentials'),(8,'type','org.springframework.security.authentication.BadCredentialsException'),(9,'message','Bad credentials'),(9,'type','org.springframework.security.authentication.BadCredentialsException');
/*!40000 ALTER TABLE `jhi_persistent_audit_evt_data` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `jhi_user`
--
DROP TABLE IF EXISTS `jhi_user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `jhi_user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`login` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`password_hash` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL,
`first_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`last_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`email` varchar(254) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`image_url` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`activated` bit(1) NOT NULL,
`lang_key` varchar(6) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`activation_key` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`reset_key` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_by` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_date` timestamp NOT NULL DEFAULT current_timestamp(),
`reset_date` timestamp NULL DEFAULT NULL,
`last_modified_by` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`last_modified_date` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ux_user_login` (`login`),
UNIQUE KEY `ux_user_email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `jhi_user`
--
LOCK TABLES `jhi_user` WRITE;
/*!40000 ALTER TABLE `jhi_user` DISABLE KEYS */;
INSERT INTO `jhi_user` VALUES (1,'system','$2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG','System','System','system@localhost','','','en',NULL,NULL,'system','2019-01-09 00:13:48',NULL,'system',NULL),(2,'anonymoususer','$2a$10$j8S5d7Sr7.8VTOYNviDPOeWX8KcYILUVJBsYV83Y5NtECayypx9lO','Anonymous','User','anonymous@localhost','','','en',NULL,NULL,'system','2019-01-09 00:13:48',NULL,'system',NULL),(3,'admin','$2a$10$gSAhZrxMllrbgj/kkK9UceBPpChGWJA7SYIb1Mqo.n5aNLq1/oRrC','Administrator','Administrator','admin@localhost','','','en',NULL,NULL,'system','2019-01-09 00:13:48',NULL,'system',NULL),(4,'user','$2a$10$VEjxo0jq2YG9Rbk2HmX9S.k1uZBGYUHdUcid3g/vfiEl7lwWgOH/K','User','User','user@localhost','','','en',NULL,NULL,'system','2019-01-09 00:13:48',NULL,'system',NULL),(5,'testuser','$2a$10$3if98GHKIMZpxniMI4z51.SDKDMNbdr5zUSHZTkJrKE.iq7pzUIfq','Test','Testowy','<EMAIL>',NULL,'','pl',NULL,NULL,'anonymousUser','2019-01-09 00:16:08',NULL,'admin','2019-01-09 00:17:24');
/*!40000 ALTER TABLE `jhi_user` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `jhi_user_authority`
--
DROP TABLE IF EXISTS `jhi_user_authority`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `jhi_user_authority` (
`user_id` bigint(20) NOT NULL,
`authority_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`user_id`,`authority_name`),
KEY `fk_authority_name` (`authority_name`),
CONSTRAINT `fk_authority_name` FOREIGN KEY (`authority_name`) REFERENCES `jhi_authority` (`name`),
CONSTRAINT `fk_user_id` FOREIGN KEY (`user_id`) REFERENCES `jhi_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `jhi_user_authority`
--
LOCK TABLES `jhi_user_authority` WRITE;
/*!40000 ALTER TABLE `jhi_user_authority` DISABLE KEYS */;
INSERT INTO `jhi_user_authority` VALUES (1,'ROLE_ADMIN'),(1,'ROLE_USER'),(3,'ROLE_ADMIN'),(3,'ROLE_USER'),(4,'ROLE_USER'),(5,'ROLE_ADMIN'),(5,'ROLE_USER');
/*!40000 ALTER TABLE `jhi_user_authority` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `refuels`
--
DROP TABLE IF EXISTS `refuels`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `refuels` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`cost_in_cents` int(11) NOT NULL,
`station` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`date` date NOT NULL,
`mileage` int(11) NOT NULL,
`volume_in_cm3` int(11) DEFAULT NULL,
`vehicle_id` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK7cs5c7iw40lj73yo6s77u7rvl` (`vehicle_id`),
CONSTRAINT `FK7cs5c7iw40lj73yo6s77u7rvl` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicles` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `refuels`
--
LOCK TABLES `refuels` WRITE;
/*!40000 ALTER TABLE `refuels` DISABLE KEYS */;
INSERT INTO `refuels` VALUES (1,10000,'CPN','2018-01-04',100000,21500,1),(2,10000,'','2018-01-20',100389,22500,1),(3,10000,'','2018-02-10',100800,22000,1),(4,10000,'','2018-02-28',101400,23000,1),(5,10000,'','2018-03-14',101680,21000,1),(6,10000,'CPN','2018-04-02',102100,21750,1),(7,10000,'','2018-04-20',102500,22000,1),(8,10000,'','2018-05-07',102879,22225,1),(9,12500,'','2018-05-26',103300,27500,1),(10,10000,'','2018-06-12',104005,22000,1),(11,12500,'','2018-07-02',104500,27250,1),(12,11175,'CPN','2018-07-14',104850,25000,1),(13,15000,'Shell Italy','2018-07-15',105862,25050,1),(14,15000,'Shell Italy','2018-07-30',106425,25125,1),(15,10000,'CPN','2018-08-13',107000,22000,1),(16,11000,'','2018-09-01',107450,25000,1),(17,10000,'','2018-09-15',108005,21750,1),(18,10000,'','2018-09-29',108500,21500,1),(19,10000,'','2018-10-12',109001,21250,1),(20,10000,'','2018-10-28',109400,22000,1),(21,10000,'','2018-11-14',110000,21225,1),(22,11000,'','2018-12-01',110580,25000,1),(23,10000,'CPN','2018-12-22',111011,22000,1),(24,33800,'CPN','2018-01-04',200000,67188,3),(25,33800,'','2018-01-20',200778,70313,3),(26,33800,'','2018-02-10',201600,68750,3),(27,33800,'','2018-02-28',202800,71875,3),(28,33800,'','2018-03-14',203360,65625,3),(29,33800,'CPN','2018-04-02',204200,67970,3),(30,33800,'','2018-04-20',205000,68750,3),(31,33800,'','2018-05-07',205758,69453,3),(32,42250,'','2018-05-26',206600,85938,3),(33,33800,'','2018-06-12',208010,68750,3),(34,42250,'','2018-07-02',209000,85158,3),(35,37773,'CPN','2018-07-14',209700,78125,3),(36,50700,'Shell Italy','2018-07-15',211724,78283,3),(37,50700,'Shell Italy','2018-07-30',212850,78515,3),(38,33800,'CPN','2018-08-13',214000,68750,3),(39,37180,'','2018-09-01',214900,78125,3),(40,33800,'','2018-09-15',216010,67970,3),(41,33800,'','2018-09-29',217000,67188,3),(42,33800,'','2018-10-12',218002,66408,3),(43,33800,'','2018-10-28',218800,68750,3),(44,33800,'','2018-11-14',220000,66328,3),(45,37180,'','2018-12-01',221160,78125,3),(46,33800,'CPN','2018-12-22',222022,68750,3);
/*!40000 ALTER TABLE `refuels` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `reminder_advances`
--
DROP TABLE IF EXISTS `reminder_advances`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `reminder_advances` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`type` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UC_REMINDER_ADVANCESTYPE_COL` (`type`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `reminder_advances`
--
LOCK TABLES `reminder_advances` WRITE;
/*!40000 ALTER TABLE `reminder_advances` DISABLE KEYS */;
INSERT INTO `reminder_advances` VALUES (1,3),(2,7),(3,14),(4,30);
/*!40000 ALTER TABLE `reminder_advances` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `repairs`
--
DROP TABLE IF EXISTS `repairs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `repairs` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`cost_in_cents` int(11) NOT NULL,
`details` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`station` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`date` date NOT NULL,
`mileage` int(11) NOT NULL,
`vehicle_id` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `FKr8rwhlbv43kxbn4j93hkul7ax` (`vehicle_id`),
CONSTRAINT `FKr8rwhlbv43kxbn4j93hkul7ax` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicles` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `repairs`
--
LOCK TABLES `repairs` WRITE;
/*!40000 ALTER TABLE `repairs` DISABLE KEYS */;
INSERT INTO `repairs` VALUES (1,20000,'Poduszka pod silnikiem','AutoService','2018-04-20',102500,1),(2,50000,'Malowanie zderzaka','Blacharstwo','2018-11-05',109800,1),(3,250000,'Sprzęgło dwumasowe','AutoProf','2018-08-30',214880,3);
/*!40000 ALTER TABLE `repairs` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `routine_services`
--
DROP TABLE IF EXISTS `routine_services`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `routine_services` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`cost_in_cents` int(11) NOT NULL,
`details` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`next_by_date` date DEFAULT NULL,
`next_by_mileage` int(11) DEFAULT NULL,
`station` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`date` date NOT NULL,
`mileage` int(11) NOT NULL,
`vehicle_id` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `FKsy0jrbbtf29lpv37ahmtlj3dv` (`vehicle_id`),
CONSTRAINT `FKsy0jrbbtf29lpv37ahmtlj3dv` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicles` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `routine_services`
--
LOCK TABLES `routine_services` WRITE;
/*!40000 ALTER TABLE `routine_services` DISABLE KEYS */;
INSERT INTO `routine_services` VALUES (1,30000,'Olej\nFiltr oleju\nFiltr paliwa','2020-02-26',116200,'AutoService','2018-02-26',101200,1),(2,8000,'Wymiana opon','2018-10-22',0,'OponySerwis','2018-04-09',102200,1),(3,8000,'Wymiana opon\nWyważanie kół','2019-04-09',0,'OponySerwis','2018-10-20',109200,1),(4,8000,'Wymiana opon','2019-10-21',0,'Opony u Tomka','2018-04-23',205200,3),(5,8000,'Wymiana opon','2019-04-22',0,'Opony u Tomka','2018-10-20',218400,3),(6,50000,'Wymiana łańcucha rozrządu','2030-01-31',400000,'AutoProf','2018-03-14',203460,3);
/*!40000 ALTER TABLE `routine_services` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vehicles`
--
DROP TABLE IF EXISTS `vehicles`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `vehicles` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`license_plate` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
`make` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`model` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`engine_power_in_kw` int(11) DEFAULT NULL,
`engine_volume_in_cm3` int(11) DEFAULT NULL,
`image` longblob DEFAULT NULL,
`model_suffix` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`notes` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`registration_certificate` varchar(14) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`vehicle_card` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`vin_number` varchar(17) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`weight_in_kg` int(11) DEFAULT NULL,
`year_of_manufacture` int(11) DEFAULT NULL,
`fuel_type_id` bigint(20) NOT NULL,
`owner_id` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `FKck94koff5phplxnts3lahjinu` (`fuel_type_id`),
KEY `FKhm05kh6d8f082pgddom1q1yco` (`owner_id`),
CONSTRAINT `FKck94koff5phplxnts3lahjinu` FOREIGN KEY (`fuel_type_id`) REFERENCES `fuel_types` (`id`),
CONSTRAINT `FKhm05kh6d8f082pgddom1q1yco` FOREIGN KEY (`owner_id`) REFERENCES `jhi_user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vehicles`
--
LOCK TABLES `vehicles` WRITE;
/*!40000 ALTER TABLE `vehicles` DISABLE KEYS */;
INSERT INTO `vehicles` VALUES (1,'DTR 2963','Ford','Focus',80,1800,'','MK2','Przykładowa notatka','FA/ZY551352877','OBY6919921','LWZPOZUFADPRLGRC0',1300,2008,1,5),(2,'DB 7087','Fiat','Tipo',90,1600,'','','','CR/QM662072044','JRF3585827','JKISATJ6FVVWXDM0W',1150,2018,2,5),(3,'DTR 5713','BMW','X5',140,3500,'','3','','BZ/IR903472581','ZZC6122833','QBU6UX6WWDTJFHCJM',2100,2012,1,5);
/*!40000 ALTER TABLE `vehicles` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping routines for database 'carcare'
--
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2019-01-10 21:21:31
|
<filename>create/team_info_create.sql
CREATE TABLE nhl.team_info
(
team_id bigint NOT NULL,
franchiseId smallint,
shortName varchar(255),
teamName varchar(255),
abbreviation varchar(255),
link varchar(255),
PRIMARY KEY (team_id)
)
TABLESPACE pg_default;
ALTER TABLE nhl.team_info
OWNER to cc3201; |
<reponame>Websilk/Old
CREATE SEQUENCE [dbo].[SequencePages]
AS BIGINT
START WITH 100
INCREMENT BY 1
NO CACHE;
|
<reponame>cenkerkaraors/CS202-Project<filename>queries/product.sql
use [hw2DB]
CREATE TABLE Product_AM (
altitude_level INT NOT NULL,
min_temp INT NOT NULL,
PRIMARY KEY (altitude_level),
);
CREATE TABLE Product_PH (
pid INT NOT NULL,
plant_date DATE NOT NULL,
harvest_date DATE NOT NULL,
PRIMARY KEY (pid),
);
CREATE TABLE Product (
pid INT NOT NULL,
pname VARCHAR(15) NOT NULL,
plant_date DATE NOT NULL,
hardness_level VARCHAR(3) NOT NULL,
altitude_level INT NOT NULL,
PRIMARY KEY (pid),
FOREIGN KEY (pid) REFERENCES Product_PH (pid),
FOREIGN KEY (altitude_level) REFERENCES Product_AM (altitude_level)
); |
CREATE TABLE IF NOT EXISTS
simpsons(
id SERIAL PRIMARY KEY NOT NULL,
quote VARCHAR(256) NOT NULL,
character VARCHAR(256) NOT NULL,
image VARCHAR NOT NULL,
characterDirection VARCHAR NOT NULL
);
|
--DROP TABLE IF EXISTS employees;
CREATE TABLE IF NOT EXISTS employees(
employeeid VARCHAR(255) NOT NULL,
firstname VARCHAR(255) NOT NULL,
lastname VARCHAR(255),
country VARCHAR(100),
dateofbirth TIMESTAMP,
PRIMARY KEY(employeeid)
);
--INSERT INTO employees(employeeid, firstname, lastname, country, dateofbirth) VALUES('I1','First','Employee','India', '1980-12-1 00:00:00'); |
<gh_stars>0
SELECT *
FROM SCHEDULE, AIRCRAFTS
WHERE SCHEDULE.aid=AIRCRAFTS.aid |
CREATE TABLE project (
project_id SERIAL PRIMARY KEY,
project_name varchar (128) NOT NULL,
project_note text,
project_type varchar (16) NOT NULL, -- 'personal' or 'team', only one of user_id or team_id will be used
project_public boolean NOT NULL, -- public project or private project
user_id integer REFERENCES users(user_id) ON DELETE CASCADE,
team_id integer REFERENCES team(team_id) ON DELETE CASCADE,
admin_id integer NOT NULL REFERENCES users(user_id) ON DELETE RESTRICT,
created_at timestamp NOT NULL
);
|
<gh_stars>1-10
INSERT INTO regions VALUES (E'0',E'Nasional', 0, false, NULL, NULL, NULL,'2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'11',E'Aceh', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'12',E'Sumatra Utara', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'13',E'Sumatra Barat', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'14',E'Riau', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'15',E'Jambi', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'16',E'Sumatra Selatan', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'17',E'Bengkulu', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'18',E'Lampung', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'19',E'Kepulauan Bangka Belitung', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'21',E'Kepulauan Riau', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'31',E'DKI Jakarta', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'32',E'Jawa Barat', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'33',E'Jawa Tengah', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'34',E'DI Yogyakarta', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'35',E'Jawa Timur', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'36',E'Banten', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'51',E'Bali', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'52',E'Nusa Tenggara Barat', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'53',E'Nusa Tenggara Timur', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'61',E'Kalimantan Barat', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'62',E'Kalimantan Tengah', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'63',E'Kalimantan Selatan', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'64',E'Kalimantan Timur', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'65',E'Kalimantan Utara', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'71',E'Sulawesi Utara', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'72',E'Sulawesi Tengah', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'73',E'Sulawesi Selatan', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'74',E'Sulawesi Tenggara', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'75',E'Gorontalo', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'76',E'Sulawesi Barat', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'81',E'Maluku', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'82',E'Maluku Utara', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'91',E'Papua', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
INSERT INTO regions VALUES (E'92',E'Papua Barat', 1, false, NULL, NULL, '0','2014-12-13 04:48:57','2014-12-13 10:56:16');
|
USE [SMSService]
GO
IF OBJECT_ID('pbl.spGetAccounts') IS NOT NULL
DROP PROCEDURE pbl.spGetAccounts
GO
CREATE PROCEDURE pbl.spGetAccounts
@AID UNIQUEIDENTIFIER
, @AEnabled BIT
WITH ENCRYPTION
AS
BEGIN
SET NOCOUNT, XACT_ABORT ON;
DECLARE @ID UNIQUEIDENTIFIER = @AID
, @Enabled BIT = @AEnabled
, @Result INT = 0
IF @ID = pbl.EmptyGuid()
SET @ID = NULL
SELECT ID
, Title
, Domain
, UserName
, [Password]
, Number
, [Enabled]
, [AlertCreditAmount]
, [CreditAlertCount]
FROM pbl.Account
WHERE @Enabled is NULL OR [Enabled] = @Enabled
SET @Result = @@ROWCOUNT
RETURN @Result
END |
<gh_stars>1-10
DROP TABLE action.reporttype; |
CREATE TABLE "devices" (
"device_name" varchar PRIMARY KEY,
"last_updated" varchar NOT NULL,
"expected" varchar NOT NULL,
"price" int NOT NULL,
"img_url" varchar NOT NULL,
"source_url" varchar NOT NULL,
"spec_score" int NOT NULL,
"ram" varchar,
"processor" varchar,
"front_camera" varchar,
"rear_camera" varchar,
"battery" varchar,
"display" varchar,
"operating_system" varchar,
"custom_ui" varchar,
"chipset" varchar,
"cpu" varchar,
"architecture" varchar,
"graphics" varchar,
"display_type" varchar,
"screen_size" varchar,
"resolution" varchar,
"pixel_density" varchar,
"touchscreen" varchar,
"internal_memory" varchar,
"expandable_memory" varchar,
"m_camera_setup" varchar,
"m_resolution" varchar,
"m_autofocus" varchar,
"m_ois" varchar,
"m_sensors" varchar,
"m_flash" varchar,
"m_image_resolution" varchar,
"m_settings" varchar,
"m_shooting_modes" varchar,
"m_camera_features" varchar,
"m_video_recording" varchar,
"s_camera_setup" varchar,
"s_resolution" varchar,
"s_video_recording" varchar,
"capacity" varchar,
"removable_battery" varchar,
"wireless_charging" varchar,
"quick_charging" varchar,
"usb" varchar,
"sim_slots" varchar,
"network_support" varchar,
"fingerprint_sensor" varchar,
"other_sensors" varchar,
"scrape_timestamp" timestamp NOT NULL
);
CREATE INDEX ON "devices" ("device_name");
CREATE INDEX ON "devices" ("last_updated");
CREATE INDEX ON "devices" ("scrape_timestamp");
|
<reponame>reisvini1/ceubexpress-back<filename>prisma/migrations/20211109230915_user_is_admin/migration.sql
/*
Warnings:
- You are about to drop the column `permission` on the `role` table. All the data in the column will be lost.
- You are about to drop the column `roleId` on the `user` table. All the data in the column will be lost.
- A unique constraint covering the columns `[isUserAdmin]` on the table `role` will be added. If there are existing duplicate values, this will fail.
*/
-- DropForeignKey
ALTER TABLE `user` DROP FOREIGN KEY `user_roleId_fkey`;
-- AlterTable
ALTER TABLE `role` DROP COLUMN `permission`,
ADD COLUMN `isUserAdmin` BOOLEAN NOT NULL DEFAULT false;
-- AlterTable
ALTER TABLE `user` DROP COLUMN `roleId`,
ADD COLUMN `isUserAdmin` BOOLEAN NOT NULL DEFAULT false;
-- CreateIndex
CREATE UNIQUE INDEX `role_isUserAdmin_key` ON `role`(`isUserAdmin`);
-- AddForeignKey
ALTER TABLE `user` ADD CONSTRAINT `user_isUserAdmin_fkey` FOREIGN KEY (`isUserAdmin`) REFERENCES `role`(`isUserAdmin`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
CREATE OR REPLACE
ALGORITHM = UNDEFINED VIEW `multi_out_transaction_attach` AS
select
`t`.`id` AS `id`,
`t`.`sender_id` AS `sender_id`,
`t`.`attachment_bytes` AS `attachment_bytes`,
`t`.`type` AS `type`,
`t`.`subtype` AS `subtype`,
`t`.`amount` AS `amount`,
`t`.`fee` AS `fee`,
`t`.`timestamp` AS `timestamp`
from
`transaction` `t`
where
`t`.`type` = 0
and `t`.`subtype` <> 0
|
-- 21.01.2016 07:59
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Field SET Description='Lager, in dem die Waren für den jeweiligen Kunden kommissioniert werden.', Help=NULL, IsCentrallyMaintained='N', Name='Kommissionierlager',Updated=TO_TIMESTAMP('2016-01-21 07:59:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=554259
;
-- 21.01.2016 07:59
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Field_Trl SET IsTranslated='N' WHERE AD_Field_ID=554259
;
|
with game_log as (
select * from {{ref('games')}}
)
select * from game_log |
<filename>nodeCrawler/mysql.sql
create table projectInfoZhuJianBu(
projectId integer not null primary key AUTO_INCREMENT,
projectNum varchar(50), /*项目编号*/
shenjiIndex varchar(20), /*省级项目编号*/
area varchar(20), /*所在区划*/
conductCompany varchar(100), /*建设单位*/
uniqueCode varchar(30), /*建设单位组织机构代码(统一社会信用代码)*/
category varchar(30), /*项目分类*/
clarify varchar(50), /*建设性质*/
projectUsage varchar(50), /*工程用途*/
budget varchar(100), /*总投资*/
areaSize varchar(60), /*总面积*/
level varchar(20), /*立项级别*/
documentNum varchar(60), /*立项文号*/
version integer,
updateDate date,
last_updated_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE = InnoDB CHARSET=utf8;
create table companyInfoZhuJianBu(
companyid int(11) not null primary key AUTO_INCREMENT,
recordIndex int(5),
companyName varchar(300),
companyUniqueCode varchar(100) not null, /*组织机构代码/营业执照编号*/
lawMan varchar(30), /*企业法定代表人*/
category varchar(20), /*企业登记注册类型*/
city varchar(60), /*企业注册属地*/
address varchar(600), /*企业经营地址*/
registerPersonURL varchar(200),
projectURL varchar(200),
certificateURL varchar(200),
version integer,
information varchar(100),
updateDate date,
last_updated_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE = InnoDB CHARSET=utf8;
alter table companyInfoZhuJianBu add processedPerson boolean;
alter table companyInfoZhuJianBu add processedProject boolean;
alter table companyInfoZhuJianBu add processedCertificate boolean;
create table companyPersonInfoZhuJianBu(
companypersonid int(11) not null primary key AUTO_INCREMENT,
companyid int(11),
indexid int(5),
name varchar(100),
personalid varchar(50),
regcategory varchar(60),
regnumber varchar(50),
regmajor varchar(100),
version integer,
information varchar(100),
updateDate date,
last_updated_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT `companyPersonCompanyID` FOREIGN KEY (`companyid`) REFERENCES `companyInfoZhuJianBu` (`companyid`)
) ENGINE = InnoDB CHARSET=utf8;
create table companyProjectInfoZhuJianBu(
companyprojectid int(11) not null primary key AUTO_INCREMENT,
companyid int(11),
indexid int(5),
projectcode varchar(50),
projectname varchar(300),
projectlocation varchar(80),
projectcategory varchar(30),
projectcompany varchar(200),
version integer,
information varchar(100),
updateDate date,
last_updated_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT `companyProjectCompanyID` FOREIGN KEY (`companyid`) REFERENCES `companyInfoZhuJianBu` (`companyid`)
) ENGINE = InnoDB CHARSET=utf8;
create table companyCertificateInfoZhuJianBu(
companycertificateid int(11) not null primary key AUTO_INCREMENT,
companyid int(11),
indexid int(5),
certificatecategory varchar(30),
certificateid varchar(30),
certificatename varchar(20),
certificateissuedate varchar(30),
certificateexpiredate varchar(30),
certificateissuer varchar(200),
version integer,
information varchar(100),
updateDate date,
last_updated_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT `companyCertificateCompanyID` FOREIGN KEY (`companyid`) REFERENCES `companyInfoZhuJianBu` (`companyid`)
) ENGINE = InnoDB CHARSET=utf8;
create table companyDetailPageInfo(
companydetailpageinfoid int(11) not null primary key AUTO_INCREMENT,
companyid int(11),
pagetype varchar(50),
pagecontentraw varchar(500),
totalpage integer,
totalrecord integer,
pagesize integer,
version integer,
information varchar(100),
updateDate date,
last_updated_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT `companydetailpageinfoCompanyID` FOREIGN KEY (`companyid`) REFERENCES `companyInfoZhuJianBu` (`companyid`)
) ENGINE = InnoDB CHARSET=utf8; |
CREATE PROCEDURE [dbo].[spSaveEventAddress]
@userId nvarchar(100),
@eventId UNIQUEIDENTIFIER,
@description NVARCHAR(255),
@line1 NVARCHAR(100),
@line2 NVARCHAR(100),
@city NVARCHAR(100),
@state NVARCHAR(2),
@zipcode NVARCHAR(5)
AS
EXEC [dbo].[spSaveAddressByEntityTypeAndId] @userId = @userId, @entityType = 'Event', @entityId = @eventId,
@description = @description, @line1 = @line1, @line2 = @line2, @city = @city, @state = @state, @zipcode = @zipcode
EXEC [dbo].[spGetAddressByEventId] @eventId = @eventId;
|
<gh_stars>1-10
-- use timestamp instead of date type
-- losing time part when using date type
-- timestamp value is in UTC
ALTER TABLE TODOS
ALTER COLUMN CREATED_DATE TYPE timestamp;
ALTER TABLE TODOS
ALTER COLUMN MODIFIED_DATE TYPE timestamp;
|
<filename>schema/verify/trigger_functions/update_timestamps.sql
-- Verify ggircs-portal:function_update_timestamps on pg
begin;
select pg_get_functiondef('ggircs_portal_private.update_timestamps()'::regprocedure);
rollback;
|
IF OBJECT_ID('sales.post_return') IS NOT NULL
DROP PROCEDURE sales.post_return;
GO
CREATE PROCEDURE sales.post_return
(
@transaction_master_id bigint,
@office_id integer,
@user_id integer,
@login_id bigint,
@value_date date,
@book_date date,
@store_id integer,
@counter_id integer,
@customer_id integer,
@price_type_id integer,
@reference_number national character varying(24),
@statement_reference national character varying(2000),
@details sales.sales_detail_type READONLY,
@shipper_id integer,
@discount numeric(30, 6),
@tran_master_id bigint OUTPUT
)
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
DECLARE @reversal_tran_id bigint;
DECLARE @new_tran_id bigint;
DECLARE @book_name national character varying(50) = 'Sales Return';
DECLARE @cost_center_id bigint;
DECLARE @tran_counter integer;
DECLARE @tran_code national character varying(50);
DECLARE @checkout_id bigint;
DECLARE @grand_total numeric(30, 6);
DECLARE @discount_total numeric(30, 6);
DECLARE @is_credit bit;
DECLARE @default_currency_code national character varying(12);
DECLARE @cost_of_goods_sold numeric(30, 6);
DECLARE @ck_id bigint;
DECLARE @sales_id bigint;
DECLARE @tax_total numeric(30, 6);
DECLARE @tax_account_id integer;
DECLARE @fiscal_year_code national character varying(12);
DECLARE @can_post_transaction bit;
DECLARE @error_message national character varying(MAX);
DECLARE @original_checkout_id bigint;
DECLARE @original_customer_id integer;
DECLARE @difference sales.sales_detail_type;
SELECT
@original_customer_id = sales.sales.customer_id,
@original_checkout_id = sales.sales.checkout_id
FROM sales.sales
INNER JOIN finance.transaction_master
ON finance.transaction_master.transaction_master_id = sales.sales.transaction_master_id
AND finance.transaction_master.verification_status_id > 0
AND finance.transaction_master.transaction_master_id = @transaction_master_id;
DECLARE @new_checkout_items TABLE
(
store_id integer,
transaction_type national character varying(2),
item_id integer,
quantity numeric(30, 6),
unit_id integer,
base_quantity numeric(30, 6),
base_unit_id integer,
price numeric(30, 6),
discount_rate numeric(30, 6),
discount numeric(30, 6),
shipping_charge numeric(30, 6)
);
BEGIN TRY
DECLARE @tran_count int = @@TRANCOUNT;
IF(@tran_count= 0)
BEGIN
BEGIN TRANSACTION
END;
SELECT
@can_post_transaction = can_post_transaction,
@error_message = error_message
FROM finance.can_post_transaction(@login_id, @user_id, @office_id, @book_name, @value_date);
IF(@can_post_transaction = 0)
BEGIN
RAISERROR(@error_message, 13, 1);
RETURN;
END;
SET @tax_account_id = finance.get_sales_tax_account_id_by_office_id(@office_id);
IF(@original_customer_id IS NULL)
BEGIN
RAISERROR('Invalid transaction.', 16, 1);
END;
IF(@original_customer_id != @customer_id)
BEGIN
RAISERROR('This customer is not associated with the sales you are trying to return.', 16, 1);
END;
DECLARE @is_valid_transaction bit;
SELECT
@is_valid_transaction = is_valid,
@error_message = "error_message"
FROM sales.validate_items_for_return(@transaction_master_id, @details);
IF(@is_valid_transaction = 0)
BEGIN
RAISERROR(@error_message, 16, 1);
RETURN;
END;
SET @default_currency_code = core.get_currency_code_by_office_id(@office_id);
SET @tran_counter = finance.get_new_transaction_counter(@value_date);
SET @tran_code = finance.get_transaction_code(@value_date, @office_id, @user_id, @login_id);
SELECT @sales_id = sales.sales.sales_id
FROM sales.sales
WHERE sales.sales.transaction_master_id = @transaction_master_id;
--Returned items are subtracted
INSERT INTO @new_checkout_items(store_id, item_id, quantity, unit_id, price, discount_rate, shipping_charge)
SELECT store_id, item_id, quantity *-1, unit_id, price *-1, ROUND(discount_rate, 2), shipping_charge *-1
FROM @details;
--Original items are added
INSERT INTO @new_checkout_items(store_id, item_id, quantity, unit_id, price, discount_rate, shipping_charge)
SELECT
inventory.checkout_details.store_id,
inventory.checkout_details.item_id,
inventory.checkout_details.quantity,
inventory.checkout_details.unit_id,
inventory.checkout_details.price,
ROUND(inventory.checkout_details.discount_rate, 2),
inventory.checkout_details.shipping_charge
FROM inventory.checkout_details
WHERE checkout_id = @original_checkout_id;
UPDATE @new_checkout_items
SET
base_quantity = inventory.get_base_quantity_by_unit_id(unit_id, quantity),
base_unit_id = inventory.get_root_unit_id(unit_id),
discount = ROUND(((price * quantity) + shipping_charge) * (discount_rate / 100), 2);
IF EXISTS
(
SELECT item_id, COUNT(DISTINCT unit_id)
FROM @new_checkout_items
GROUP BY item_id
HAVING COUNT(DISTINCT unit_id) > 1
)
BEGIN
RAISERROR('A return entry must exactly macth the unit of measure provided during sales.', 16, 1);
END;
IF EXISTS
(
SELECT item_id, COUNT(DISTINCT ABS(price))
FROM @new_checkout_items
GROUP BY item_id
HAVING COUNT(DISTINCT ABS(price)) > 1
)
BEGIN
RAISERROR('A return entry must exactly macth the price provided during sales.', 16, 1);
END;
IF EXISTS
(
SELECT item_id, COUNT(DISTINCT store_id)
FROM @new_checkout_items
GROUP BY item_id
HAVING COUNT(DISTINCT store_id) > 1
)
BEGIN
RAISERROR('A return entry must exactly macth the store provided during sales.', 16, 1);
END;
INSERT INTO @difference(store_id, transaction_type, item_id, quantity, unit_id, price, discount, shipping_charge)
SELECT store_id, 'Cr', item_id, SUM(quantity), unit_id, SUM(price), SUM(discount), SUM(shipping_charge)
FROM @new_checkout_items
GROUP BY store_id, item_id, unit_id;
DELETE FROM @difference
WHERE quantity = 0;
--> REVERSE THE ORIGINAL TRANSACTION
INSERT INTO finance.transaction_master(transaction_counter, transaction_code, book, value_date, book_date, user_id, login_id, office_id, cost_center_id, reference_number, statement_reference)
SELECT @tran_counter, @tran_code, @book_name, @value_date, @book_date, @user_id, @login_id, @office_id, @cost_center_id, @reference_number, @statement_reference;
SET @reversal_tran_id = SCOPE_IDENTITY();
INSERT INTO finance.transaction_details(transaction_master_id, office_id, value_date, book_date, tran_type, account_id, statement_reference, currency_code, amount_in_currency, er, local_currency_code, amount_in_local_currency)
SELECT
@reversal_tran_id,
office_id,
value_date,
book_date,
CASE WHEN tran_type = 'Dr' THEN 'Cr' ELSE 'Dr' END,
account_id,
@statement_reference,
currency_code,
amount_in_currency,
er,
local_currency_code,
amount_in_local_currency
FROM finance.transaction_details
WHERE finance.transaction_details.transaction_master_id = @transaction_master_id;
IF EXISTS(SELECT * FROM @difference)
BEGIN
--> ADD A NEW SALES INVOICE
EXECUTE sales.post_sales
@office_id,
@user_id,
@login_id,
@counter_id,
@value_date,
@book_date,
@cost_center_id,
@reference_number,
@statement_reference,
NULL, --@tender,
NULL, --@change,
NULL, --@payment_term_id,
NULL, --@check_amount,
NULL, --@check_bank_name,
NULL, --@check_number,
NULL, --@check_date,
NULL, --@gift_card_number,
@customer_id,
@price_type_id,
@shipper_id,
@store_id,
NULL, --@coupon_code,
1, --@is_flat_discount,
@discount,
@difference,
NULL, --@sales_quotation_id,
NULL, --@sales_order_id,
@new_tran_id OUTPUT,
@book_name;
END;
ELSE
BEGIN
SET @tran_counter = finance.get_new_transaction_counter(@value_date);
SET @tran_code = finance.get_transaction_code(@value_date, @office_id, @user_id, @login_id);
INSERT INTO finance.transaction_master(transaction_counter, transaction_code, book, value_date, book_date, user_id, login_id, office_id, cost_center_id, reference_number, statement_reference)
SELECT @tran_counter, @tran_code, @book_name, @value_date, @book_date, @user_id, @login_id, @office_id, @cost_center_id, @reference_number, @statement_reference;
SET @new_tran_id = SCOPE_IDENTITY();
END;
INSERT INTO inventory.checkouts(transaction_book, value_date, book_date, transaction_master_id, office_id, posted_by, discount, taxable_total, tax_rate, tax, nontaxable_total)
SELECT @book_name, @value_date, @book_date, @new_tran_id, office_id, @user_id, discount, taxable_total, tax_rate, tax, nontaxable_total
FROM inventory.checkouts
WHERE inventory.checkouts.checkout_id = @original_checkout_id;
SET @checkout_id = SCOPE_IDENTITY();
INSERT INTO inventory.checkout_details(value_date, book_date, checkout_id, transaction_type, store_id, item_id, quantity, unit_id, base_quantity, base_unit_id, price, is_taxed, cost_of_goods_sold, discount)
SELECT @value_date, @book_date, @checkout_id,
CASE WHEN transaction_type = 'Dr' THEN 'Cr' ELSE 'Dr' END,
store_id, item_id, quantity, unit_id, base_quantity, base_unit_id, price, is_taxed, cost_of_goods_sold, discount
FROM inventory.checkout_details
WHERE inventory.checkout_details.checkout_id = @original_checkout_id;
INSERT INTO sales.returns(sales_id, checkout_id, transaction_master_id, return_transaction_master_id, counter_id, customer_id, price_type_id)
SELECT @sales_id, @checkout_id, @transaction_master_id, @new_tran_id, @counter_id, @customer_id, @price_type_id;
SET @tran_master_id = @new_tran_id;
IF(@tran_count = 0)
BEGIN
COMMIT TRANSACTION;
END;
END TRY
BEGIN CATCH
IF(XACT_STATE() <> 0 AND @tran_count = 0)
BEGIN
ROLLBACK TRANSACTION;
END;
DECLARE @ErrorMessage national character varying(4000) = ERROR_MESSAGE();
DECLARE @ErrorSeverity int = ERROR_SEVERITY();
DECLARE @ErrorState int = ERROR_STATE();
RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState);
END CATCH;
END;
GO
--DECLARE @transaction_master_id bigint = 369;
--DECLARE @office_id integer = (SELECT TOP 1 office_id FROM core.offices);
--DECLARE @user_id integer = (SELECT TOP 1 user_id FROM account.users);
--DECLARE @login_id bigint = (SELECT TOP 1 login_id FROM account.logins WHERE user_id = @user_id);
--DECLARE @value_date date = finance.get_value_date(@office_id);
--DECLARE @book_date date = finance.get_value_date(@office_id);
--DECLARE @store_id integer = (SELECT TOP 1 store_id FROM inventory.stores WHERE store_name='Cold Room RM');
--DECLARE @counter_id integer = (SELECT TOP 1 counter_id FROM inventory.counters WHERE counter_name = 'Counter 2');
--DECLARE @customer_id integer = (SELECT customer_id FROM inventory.customers WHERE customer_name = '<NAME>');
--DECLARE @price_type_id integer = (SELECT TOP 1 price_type_id FROM sales.price_types);
--DECLARE @reference_number national character varying(24) = 'N/A';
--DECLARE @statement_reference national character varying(2000) = 'Test';
--DECLARE @details sales.sales_detail_type;
--DECLARE @tran_master_id bigint;
--INSERT INTO @details(store_id, transaction_type, item_id, quantity, unit_id, price, discount, shipping_charge, is_taxed)
--SELECT @store_id, 'Cr', 1, 1, 6, 2320, 62.84, 0, 1;
--EXECUTE sales.post_return
-- @transaction_master_id ,
-- @office_id ,
-- @user_id ,
-- @login_id ,
-- @value_date ,
-- @book_date ,
-- @store_id ,
-- @counter_id ,
-- @customer_id ,
-- @price_type_id ,
-- @reference_number ,
-- @statement_reference ,
-- @details ,
-- 1,
-- 0,
-- @tran_master_id OUTPUT;
|
<filename>common/taskana-common/src/main/resources/sql/h2/taskana_schema_update_1.1.5_to_1.2.1_h2.sql
-- this script adds a unique constraint to WORKBASKET_ACCESS_LIST
-- allowing a maximum of one WORKBASKET_ACCESS_LIST per workbasket and access_id
-- Please replace %schemaName% before executing the script
SET SCHEMA %schemaName%;
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('1.2.1', CURRENT_TIMESTAMP);
-- If the database contains records that violate this constraint, the following statement will fail.
-- In this case it is required to remove the conflicting records before the constraint can be added
ALTER TABLE WORKBASKET_ACCESS_LIST ADD CONSTRAINT UC_ACCESSID_WBID UNIQUE (ACCESS_ID, WORKBASKET_ID);
|
<filename>wycms/modules/comment/uninstall/comment_table.sql
DROP TABLE IF EXISTS `wy_comment_table`;
|
-- phpMyAdmin SQL Dump
-- version 4.7.3
-- https://www.phpmyadmin.net/
--
-- Хост: 127.0.0.1:3306
-- Время создания: Июл 05 2018 г., 02:46
-- Версия сервера: 5.5.57
-- Версия PHP: 7.0.21
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- База данных: `dbwork`
--
-- --------------------------------------------------------
--
-- Структура таблицы `bids`
--
CREATE TABLE `bids` (
`id` int(11) NOT NULL,
`id_event` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`price` double NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `bids`
--
INSERT INTO `bids` (`id`, `id_event`, `name`, `email`, `price`) VALUES
(1, 1, 'Василий', '<EMAIL>', 100),
(2, 1, 'Николай', '<EMAIL>', 150),
(3, 2, 'Иван', '<EMAIL>', 120),
(4, 1, 'Петр', 'Pt<EMAIL>', 170),
(5, 1, 'Слава', 'Sv<EMAIL>', 160),
(6, 2, 'Кузя', '<EMAIL>', 90),
(7, 2, 'Саша', '<EMAIL>', 135),
(8, 2, 'Таня', '<EMAIL>', 120),
(9, 1, 'Вика', '<EMAIL>', 140);
-- --------------------------------------------------------
--
-- Структура таблицы `events`
--
CREATE TABLE `events` (
`id_event` int(11) NOT NULL,
`caption` varchar(255) NOT NULL,
`kol` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `events`
--
INSERT INTO `events` (`id_event`, `caption`, `kol`) VALUES
(1, 'Atlas Weekend 2017', 0),
(2, 'Грин Грей (Green Grey)', 0),
(3, 'Metallica', 0),
(4, 'AC / DC', 0);
-- --------------------------------------------------------
--
-- Структура таблицы `migration`
--
CREATE TABLE `migration` (
`version` varchar(180) NOT NULL,
`apply_time` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `migration`
--
INSERT INTO `migration` (`version`, `apply_time`) VALUES
('m000000_000000_base', 1530704807),
('m180704_115933_create_user_table', 1530706425);
-- --------------------------------------------------------
--
-- Структура таблицы `user`
--
CREATE TABLE `user` (
`id` int(11) NOT NULL,
`username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`auth_key` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
`password_hash` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password_reset_token` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`status` smallint(6) NOT NULL DEFAULT '1',
`created_at` date NOT NULL,
`updated_at` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Дамп данных таблицы `user`
--
INSERT INTO `user` (`id`, `username`, `auth_key`, `password_hash`, `password_reset_token`, `email`, `status`, `created_at`, `updated_at`) VALUES
(1, 'admin', '<PASSWORD>', <PASSWORD>', NULL, '<EMAIL>', 1, '0000-00-00', '0000-00-00');
--
-- Индексы сохранённых таблиц
--
--
-- Индексы таблицы `bids`
--
ALTER TABLE `bids`
ADD PRIMARY KEY (`id`),
ADD KEY `id_event` (`id_event`);
--
-- Индексы таблицы `events`
--
ALTER TABLE `events`
ADD PRIMARY KEY (`id_event`);
--
-- Индексы таблицы `migration`
--
ALTER TABLE `migration`
ADD PRIMARY KEY (`version`);
--
-- Индексы таблицы `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `username` (`username`),
ADD UNIQUE KEY `email` (`email`),
ADD UNIQUE KEY `password_reset_token` (`password_reset_token`);
--
-- AUTO_INCREMENT для сохранённых таблиц
--
--
-- AUTO_INCREMENT для таблицы `bids`
--
ALTER TABLE `bids`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT для таблицы `events`
--
ALTER TABLE `events`
MODIFY `id_event` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT для таблицы `user`
--
ALTER TABLE `user`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
-- MODULE CDR006
-- SQL Test Suite, V6.0, Interactive SQL, cdr006.sql
-- 59-byte ID
-- TEd Version #
-- AUTHORIZATION SUN
SELECT USER FROM SUN.ECCO;
-- RERUN if USER value does not match preceding AUTHORIZATION comment
-- date_time print
-- TEST:0316 CHECK <null predicate> in <tab. cons.>, update!
-- setup
DELETE FROM STAFF8;
INSERT INTO STAFF8
VALUES('E1','Alice',34,'Deale');
UPDATE STAFF8
SET EMPNAME = NULL
WHERE EMPNUM = 'E1';
-- PASS:0316 If ERROR, check constraint, 0 rows updated?
SELECT COUNT(*) FROM STAFF8
WHERE EMPNAME = 'Alice';
-- PASS:0316 If count = 1?
-- END TEST >>> 0316 <<< END TEST
-- *************************************************
-- TEST:0317 CHECK X IS NOT NULL, NOT X IS NULL same, by update!
-- setup
DELETE FROM STAFF13;
INSERT INTO STAFF13
VALUES('E1','Alice',36,'Deale');
UPDATE STAFF13
SET EMPNAME = NULL
WHERE EMPNUM = 'E1';
-- PASS:0317 If ERROR, check constraint, 0 rows updated?
SELECT COUNT(*)
FROM STAFF13
WHERE EMPNAME = 'Alice';
-- PASS:0317 If count = 1?
-- END TEST >>> 0317 <<< END TEST
-- *************************************************
-- TEST:0318 CHECK <like predicate> in <tab. cons.>, update!
-- setup
DELETE FROM STAFF9;
INSERT INTO STAFF9
VALUES('E3','Susan',11,'Hawaii');
UPDATE STAFF9
SET EMPNAME = 'Thomas'
WHERE EMPNUM = 'E3';
-- PASS:0318 If ERROR, check constraint, 0 rows updated?
SELECT COUNT(*)
FROM STAFF9
WHERE EMPNAME = 'Susan';
-- PASS:0318 If count = 1?
COMMIT WORK;
-- END TEST >>> 0318 <<< END TEST
-- *************************************************////END-OF-MODULE
|
-- @testpoint:opengauss关键字stable(非保留),作为外部数据源名
--关键字不带引号-成功
drop data source if exists stable;
create data source stable;
drop data source stable;
--关键字带双引号-成功
drop data source if exists "stable";
create data source "stable";
drop data source "stable";
--关键字带单引号-合理报错
drop data source if exists 'stable';
create data source 'stable';
--关键字带反引号-合理报错
drop data source if exists `stable`;
create data source `stable`;
|
<gh_stars>0
-- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Mar 28, 2019 at 06:03 PM
-- Server version: 10.1.37-MariaDB
-- PHP Version: 7.2.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `laravel_ecommerce`
--
-- --------------------------------------------------------
--
-- Table structure for table `admins`
--
CREATE TABLE `admins` (
`id` int(10) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone_no` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`avatar` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`type` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Supper Admin' COMMENT 'Admin|Supper Admin',
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `admins`
--
INSERT INTO `admins` (`id`, `name`, `email`, `password`, `phone_no`, `avatar`, `type`, `remember_token`, `created_at`, `updated_at`) VALUES
(1, 'mohaimen', '<EMAIL>', <PASSWORD>', '01798659099', NULL, 'Supper Admin', 'OoboqQJGlgjtYRTmuFNFjUzxzs4czhSmriz1a08xsEoCHnJ2g7BsnUyAsIEB', NULL, '2019-03-25 14:26:58');
-- --------------------------------------------------------
--
-- Table structure for table `brands`
--
CREATE TABLE `brands` (
`id` int(10) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_ci,
`image` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `brands`
--
INSERT INTO `brands` (`id`, `name`, `description`, `image`, `created_at`, `updated_at`) VALUES
(2, 'Samsung', 'samsung is the most popular brand in the world.', 'samsung.png', '2019-02-27 14:22:08', '2019-02-27 14:22:08'),
(3, 'LG', 'lg is the popular brand', '1551277597.jpg', '2019-02-27 08:26:37', '2019-02-27 08:26:37'),
(4, 'Apple', 'apple is the best brand', '1551278160.png', '2019-02-27 08:28:16', '2019-02-27 08:36:00'),
(5, 'Others', 'other brand', '1551503820.jpg', '2019-03-01 23:17:00', '2019-03-01 23:17:00'),
(6, 'Philips', NULL, '1551506510.jpg', '2019-03-02 00:01:50', '2019-03-02 00:01:50'),
(7, 'Coca cola', 'Coca cola', NULL, '2019-03-02 00:40:55', '2019-03-02 00:40:55');
-- --------------------------------------------------------
--
-- Table structure for table `carts`
--
CREATE TABLE `carts` (
`id` int(10) UNSIGNED NOT NULL,
`product_id` int(10) UNSIGNED NOT NULL,
`user_id` int(10) UNSIGNED DEFAULT NULL,
`order_id` int(10) UNSIGNED DEFAULT NULL,
`ip_address` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`product_quantity` int(191) NOT NULL DEFAULT '1',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `carts`
--
INSERT INTO `carts` (`id`, `product_id`, `user_id`, `order_id`, `ip_address`, `product_quantity`, `created_at`, `updated_at`) VALUES
(28, 1, 19, 5, '127.0.0.1', 2, '2019-03-19 01:25:52', '2019-03-27 13:54:05'),
(32, 12, NULL, 5, '127.0.0.1', 1, '2019-03-19 05:37:35', '2019-03-27 13:51:50'),
(34, 15, 19, 5, '127.0.0.1', 1, '2019-03-19 12:38:28', '2019-03-22 13:21:22'),
(35, 14, 19, 5, '127.0.0.1', 2, '2019-03-19 12:38:34', '2019-03-22 13:35:48'),
(36, 12, 19, 6, '127.0.0.1', 1, '2019-03-23 07:55:30', '2019-03-23 07:56:14'),
(37, 16, 19, 6, '127.0.0.1', 1, '2019-03-23 07:55:38', '2019-03-23 07:56:14');
-- --------------------------------------------------------
--
-- Table structure for table `categories`
--
CREATE TABLE `categories` (
`id` int(10) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_ci,
`image` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`parent_id` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `categories`
--
INSERT INTO `categories` (`id`, `name`, `description`, `image`, `parent_id`, `created_at`, `updated_at`) VALUES
(8, 'Accessorices', 'Samsung', '1550682686.png', NULL, '2019-02-20 11:11:26', '2019-03-02 12:35:28'),
(9, 'Headphone', 'Samsung Headphone', '1550683424.png', 8, '2019-02-20 11:23:44', '2019-02-20 11:23:44'),
(12, 'Earphone', 'Earphone v2.0', '1550684720.jpg', 8, '2019-02-20 11:45:20', '2019-02-22 09:50:27'),
(13, 'Fridge', 'FridgeFridge', '1550687341.jpg', 14, '2019-02-20 12:29:01', '2019-03-02 12:30:12'),
(14, 'Electronics', 'Air ConditionarAir Conditionar', '1550859428.jpg', NULL, '2019-02-20 12:29:25', '2019-02-27 03:45:15'),
(15, 'Samsung Smart Tv', 'Samsung Smart TvSamsung Smart Tv', '1550687407.jpeg', 8, '2019-02-20 12:30:07', '2019-02-20 12:30:08'),
(16, 'Watches', 'Watchesinc.', '1551260767.png', NULL, '2019-02-20 12:31:46', '2019-02-27 03:46:07'),
(17, 'Apple watch', 'aple aple', '1550687608.png', 16, '2019-02-20 12:33:28', '2019-02-20 12:33:28'),
(18, 'Mobile Phones', 'Mobile Phones', '1551260627.jpg', NULL, '2019-02-27 03:43:47', '2019-02-27 03:43:47'),
(19, 'Personal Care', 'Personal Care', '1551260677.jpg', NULL, '2019-02-27 03:44:37', '2019-02-27 03:44:38'),
(20, 'Fish', 'Fish', '1551261461.jpg', NULL, '2019-02-27 03:57:41', '2019-02-27 03:57:41'),
(21, 'Other', 'others', '1551506366.gif', NULL, '2019-03-01 23:54:43', '2019-03-01 23:59:26'),
(22, 'Loshon', NULL, NULL, 19, '2019-03-02 12:48:45', '2019-03-02 12:48:45'),
(23, 'test', 'sfdsadfa', '1552061099.png', NULL, '2019-03-08 10:04:59', '2019-03-08 10:04:59');
-- --------------------------------------------------------
--
-- Table structure for table `districts`
--
CREATE TABLE `districts` (
`id` int(10) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`division_id` tinyint(3) UNSIGNED NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `districts`
--
INSERT INTO `districts` (`id`, `name`, `division_id`, `created_at`, `updated_at`) VALUES
(3, 'Comilla', 1, '2019-03-06 01:31:52', '2019-03-06 01:49:18'),
(6, '<NAME>', 9, '2019-03-06 07:53:29', '2019-03-06 07:53:29');
-- --------------------------------------------------------
--
-- Table structure for table `divisions`
--
CREATE TABLE `divisions` (
`id` int(10) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`priority` tinyint(3) UNSIGNED NOT NULL DEFAULT '1',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `divisions`
--
INSERT INTO `divisions` (`id`, `name`, `priority`, `created_at`, `updated_at`) VALUES
(1, 'Dhaka', 1, '2019-03-05 02:31:59', '2019-03-05 02:50:23'),
(5, 'Khulna', 4, '2019-03-06 07:34:32', '2019-03-06 07:34:32'),
(6, 'Chittagong', 5, '2019-03-06 07:34:41', '2019-03-06 07:34:41'),
(7, 'Rajshahi', 6, '2019-03-06 07:34:56', '2019-03-06 07:34:56'),
(8, 'Barisal', 7, '2019-03-06 07:35:08', '2019-03-06 07:35:08'),
(9, 'Mymensingh', 2, '2019-03-06 07:53:06', '2019-03-06 07:53:16');
-- --------------------------------------------------------
--
-- Table structure for table `featureds`
--
CREATE TABLE `featureds` (
`id` int(10) UNSIGNED NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `migrations`
--
CREATE TABLE `migrations` (
`id` int(10) UNSIGNED NOT NULL,
`migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `migrations`
--
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(2, '2014_10_12_100000_create_password_resets_table', 1),
(3, '2019_02_17_101327_create_categories_table', 1),
(4, '2019_02_17_154744_create_brands_table', 1),
(5, '2019_02_17_154857_create_products_table', 1),
(7, '2019_02_17_155102_create_featureds_table', 1),
(8, '2019_02_18_065856_create_product_images_table', 1),
(11, '2014_10_12_000000_create_users_table', 2),
(12, '2019_03_05_073321_create_divisions_table', 3),
(13, '2019_03_05_073700_create_districts_table', 3),
(15, '2019_03_16_055002_create_carts_table', 4),
(16, '2019_03_20_064717_create_settings_table', 5),
(17, '2019_03_20_104406_create_payments_table', 6),
(18, '2019_03_16_054754_create_orders_table', 7),
(20, '2019_02_17_154956_create_admins_table', 8);
-- --------------------------------------------------------
--
-- Table structure for table `orders`
--
CREATE TABLE `orders` (
`id` int(10) UNSIGNED NOT NULL,
`user_id` int(10) UNSIGNED DEFAULT NULL,
`payment_id` int(10) UNSIGNED DEFAULT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone_no` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`shipping_address` text COLLATE utf8mb4_unicode_ci NOT NULL,
`message` text COLLATE utf8mb4_unicode_ci,
`ip_address` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`is_paid` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
`is_completed` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
`is_seen_by_admin` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
`transaction_id` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `orders`
--
INSERT INTO `orders` (`id`, `user_id`, `payment_id`, `name`, `phone_no`, `email`, `shipping_address`, `message`, `ip_address`, `is_paid`, `is_completed`, `is_seen_by_admin`, `transaction_id`, `created_at`, `updated_at`) VALUES
(5, 19, 3, '<NAME>', '01798659099', '<EMAIL>', 'Dhanmondi', NULL, '127.0.0.1', '0', '0', '1', 'AXDT5DL6A', '2019-03-22 13:21:22', '2019-03-27 14:58:00'),
(6, 19, 2, '<NAME>', '01798659099', '<EMAIL>', 'Dhanmondi', NULL, '127.0.0.1', '0', '0', '1', 'gfhgfjhgfjhgfj', '2019-03-23 07:56:14', '2019-03-27 15:27:18');
-- --------------------------------------------------------
--
-- Table structure for table `password_resets`
--
CREATE TABLE `password_resets` (
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `payments`
--
CREATE TABLE `payments` (
`id` int(10) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`image` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`priority` tinyint(4) NOT NULL DEFAULT '1',
`short_name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`no` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'payment No',
`type` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'agent|personal',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `payments`
--
INSERT INTO `payments` (`id`, `name`, `image`, `priority`, `short_name`, `no`, `type`, `created_at`, `updated_at`) VALUES
(1, 'Cash In Delivery', 'Cash_in.jpg', 1, 'Cash_in', NULL, NULL, '2019-03-20 13:23:49', '2019-03-20 13:23:49'),
(2, 'Bkash', 'bkash.jpg', 2, 'Bkash', '017986590991', 'Personal', '2019-03-20 13:23:49', '2019-03-20 13:23:49'),
(3, 'Rocket', 'roket.jpg', 3, 'Roket', '017986590991', 'Personal', '2019-03-20 13:23:49', '2019-03-20 13:23:49'),
(5, 'Nexus Pay', 'nexuspay.jpg', 4, 'Nexuspay', NULL, NULL, '2019-03-21 06:00:17', '2019-03-21 06:00:17');
-- --------------------------------------------------------
--
-- Table structure for table `products`
--
CREATE TABLE `products` (
`id` int(10) UNSIGNED NOT NULL,
`category_id` int(10) UNSIGNED NOT NULL,
`brand_id` int(10) UNSIGNED NOT NULL,
`title` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_ci NOT NULL,
`slug` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`quantity` int(11) NOT NULL DEFAULT '1',
`price` int(11) NOT NULL,
`status` tinyint(4) NOT NULL DEFAULT '0',
`offer_price` int(11) DEFAULT NULL,
`admin_id` int(10) UNSIGNED NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `products`
--
INSERT INTO `products` (`id`, `category_id`, `brand_id`, `title`, `description`, `slug`, `quantity`, `price`, `status`, `offer_price`, `admin_id`, `created_at`, `updated_at`) VALUES
(1, 21, 7, 'Coke 1L', 'A Coke® tastes the same no matter who you are, what you look like, what you believe, or who you love. And more than ever, we believe that', 'Coca-cola', 1, 110, 1, NULL, 1, '2019-02-17 18:00:00', '2019-02-17 18:00:00'),
(2, 8, 2, 'Samsung Galaxy', 'samsung Galaxy tastes the same no matter who you are, what you look like, what you believe, or who you love. And more than ever, we believe that', 'Samsung-Galaxy', 1, 10000, 1, NULL, 1, '2019-02-17 18:00:00', '2019-02-17 18:00:00'),
(5, 8, 2, 'Samsung Headphone', 'Razer Kraken 7.1 V2 - Digital Gaming Headset\r\n[ 1.00 EA ]', 'samsung-headphone', 2, 7500, 1, NULL, 1, '2019-02-19 01:57:55', '2019-02-19 01:57:55'),
(6, 8, 2, 'Samsung Headphone Lite', 'Baseus CAMTYW-01 Micro USB/Type C Data Cable CAMTYW-01', 'samsung-headphone-lite', 3, 5555, 1, NULL, 1, '2019-02-19 03:42:46', '2019-02-19 03:42:46'),
(7, 21, 5, 'Test post', 'Test post', 'test-post', 1, 2000, 0, NULL, 1, '2019-02-23 02:35:27', '2019-02-23 02:35:27'),
(8, 8, 2, 'Fridge', 'Samsung Fridge', 'fridge', 2, 50000, 1, NULL, 1, '2019-02-23 02:35:59', '2019-02-23 02:35:59'),
(9, 16, 4, 'Apple', 'Apple watch', 'apple', 4, 46000, 0, NULL, 1, '2019-02-23 02:36:51', '2019-02-23 02:50:28'),
(10, 9, 3, 'Headphone v2.0', 'Headphone', 'headphone-v20', 3, 1200, 0, NULL, 1, '2019-02-23 02:37:24', '2019-02-23 02:37:24'),
(11, 13, 3, 'LG AC', 'LG ac', 'lg-ac', 1, 3000, 0, NULL, 1, '2019-02-23 02:38:36', '2019-02-23 02:38:36'),
(12, 17, 4, 'Apple watch series 4', 'Apple watch', 'apple-watch-series-4', 1, 500, 1, NULL, 1, '2019-02-23 02:49:21', '2019-02-23 02:49:55'),
(14, 14, 6, 'Mixer Grinder Philips HL7710', 'Auto cut off- Yes \r\nChutney Jar- 0.4 L \r\nMultipurpose Jar- 1 L \r\nSpeed setting- 4\r\nWet Jar- 1.5 L \r\nCord length- 1.2 m \r\nVoltage- 230 V ', 'mixer-grinder-philips-hl7710', 2, 6500, 0, NULL, 1, '2019-03-02 00:03:26', '2019-03-02 00:03:26'),
(15, 14, 5, 'DryIron NI-27AWT', 'Powerful 1000W \r\n Non-Stick Coating Sole Plate\r\n Deluxe Metal Cover \r\n Big Thermostatic Pilot Lamp \r\n Heat-Resistant Cotton Cord \r\n Easy Operation 6 Temperature Settings\r\n', 'dryiron-ni-27awt', 3, 600, 0, NULL, 1, '2019-03-02 00:05:06', '2019-03-02 00:05:06'),
(16, 17, 4, 'Apple watch series 3', 'Apple watch 3 |white color', 'apple-watch-series-3', 4, 50000, 0, NULL, 1, '2019-03-02 11:15:07', '2019-03-02 11:15:07'),
(17, 20, 5, 'Fish', 'Fish', 'fish', 3, 4545, 0, NULL, 1, '2019-03-02 12:40:36', '2019-03-03 10:22:32');
-- --------------------------------------------------------
--
-- Table structure for table `product_images`
--
CREATE TABLE `product_images` (
`id` int(10) UNSIGNED NOT NULL,
`product_id` int(10) UNSIGNED NOT NULL,
`image` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `product_images`
--
INSERT INTO `product_images` (`id`, `product_id`, `image`, `created_at`, `updated_at`) VALUES
(1, 1, '1.png', '2019-02-17 18:00:00', '2019-02-17 18:00:00'),
(2, 2, '2.jpg', '2019-02-17 18:00:00', '2019-02-17 18:00:00'),
(3, 5, '1550563075.png', '2019-02-19 01:57:55', '2019-02-19 01:57:55'),
(4, 6, '1550569366.jpg', '2019-02-19 03:42:46', '2019-02-19 03:42:46'),
(5, 6, '1550569366.jpg', '2019-02-19 03:42:46', '2019-02-19 03:42:46'),
(6, 6, '1550569366.jpg', '2019-02-19 03:42:46', '2019-02-19 03:42:46'),
(8, 8, '1550570791.png', '2019-02-19 04:06:31', '2019-02-19 04:06:31'),
(9, 9, '1550571217.jpg', '2019-02-19 04:13:37', '2019-02-19 04:13:37'),
(10, 9, '1550571217.png', '2019-02-19 04:13:37', '2019-02-19 04:13:37'),
(11, 9, '1550571217.jpg', '2019-02-19 04:13:37', '2019-02-19 04:13:37'),
(12, 10, '1550581758.png', '2019-02-19 07:09:18', '2019-02-19 07:09:18'),
(13, 11, '1550589295.jpg', '2019-02-19 09:14:55', '2019-02-19 09:14:55'),
(14, 11, '1550589295.jpg', '2019-02-19 09:14:55', '2019-02-19 09:14:55'),
(15, 7, '1550910927.jpeg', '2019-02-23 02:35:28', '2019-02-23 02:35:28'),
(16, 8, '1550910959.jpg', '2019-02-23 02:35:59', '2019-02-23 02:35:59'),
(17, 9, '1550911011.png', '2019-02-23 02:36:51', '2019-02-23 02:36:51'),
(18, 10, '1550911044.png', '2019-02-23 02:37:24', '2019-02-23 02:37:24'),
(19, 11, '1550911116.jpg', '2019-02-23 02:38:36', '2019-02-23 02:38:36'),
(20, 12, '1550911761.png', '2019-02-23 02:49:21', '2019-02-23 02:49:21'),
(21, 13, '1551506237.gif', '2019-03-01 23:57:17', '2019-03-01 23:57:17'),
(22, 14, '1551506606.png', '2019-03-02 00:03:26', '2019-03-02 00:03:26'),
(23, 15, '1551506706.png', '2019-03-02 00:05:06', '2019-03-02 00:05:06'),
(24, 16, '1551546907.jpg', '2019-03-02 11:15:07', '2019-03-02 11:15:07'),
(25, 17, '1551552036.jpg', '2019-03-02 12:40:37', '2019-03-02 12:40:37');
-- --------------------------------------------------------
--
-- Table structure for table `settings`
--
CREATE TABLE `settings` (
`id` int(10) UNSIGNED NOT NULL,
`email` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`phone` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`address` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`shipping_cost` int(10) UNSIGNED NOT NULL DEFAULT '100',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `settings`
--
INSERT INTO `settings` (`id`, `email`, `phone`, `address`, `shipping_cost`, `created_at`, `updated_at`) VALUES
(1, '<EMAIL>', '017986590989', 'Dhaka-1200, Dhaka', 100, NULL, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(10) UNSIGNED NOT NULL,
`first_name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`last_name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`username` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone_no` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`street_address` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`division_id` int(10) UNSIGNED NOT NULL COMMENT 'Division table ID',
`district_id` int(10) UNSIGNED NOT NULL COMMENT 'District table ID',
`status` tinyint(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '0=Inactive|1=active',
`avatar` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`shipping_address` text COLLATE utf8mb4_unicode_ci,
`ip_address` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `first_name`, `last_name`, `username`, `phone_no`, `email`, `password`, `street_address`, `division_id`, `district_id`, `status`, `avatar`, `shipping_address`, `ip_address`, `email_verified_at`, `remember_token`, `created_at`, `updated_at`) VALUES
(19, 'Abdul', 'Mohaimen', 'AbdulMohaimen', '01798659099', '<EMAIL>', <PASSWORD>', '59/2/A', 9, 6, 1, NULL, 'Dhanmondi', '127.0.0.1', NULL, '5WX7z1BnKfjBmyFdvEBJFDrj7bn7teHiU1ZtyMbKXnEYYYDB3wPibfXW8op0', '2019-03-11 09:49:58', '2019-03-15 14:18:09'),
(20, 'Abdul', 'Mosabbir', 'abdulmosabbir', '01558383483', '<EMAIL>', <PASSWORD>', 'Fulbaria, mymensingh', 9, 6, 1, NULL, NULL, '127.0.0.1', NULL, '15bTHuzKDwlZHWto7IbB91NcjEgN92KY7vLz85ZbZYXmbpgYs6kTp8q9jvoH', '2019-03-18 09:08:12', '2019-03-18 09:08:12');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admins`
--
ALTER TABLE `admins`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `admins_email_unique` (`email`);
--
-- Indexes for table `brands`
--
ALTER TABLE `brands`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `carts`
--
ALTER TABLE `carts`
ADD PRIMARY KEY (`id`),
ADD KEY `carts_user_id_foreign` (`user_id`),
ADD KEY `carts_product_id_foreign` (`product_id`),
ADD KEY `carts_order_id_foreign` (`order_id`);
--
-- Indexes for table `categories`
--
ALTER TABLE `categories`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `districts`
--
ALTER TABLE `districts`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `divisions`
--
ALTER TABLE `divisions`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `featureds`
--
ALTER TABLE `featureds`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
ADD PRIMARY KEY (`id`),
ADD KEY `orders_user_id_foreign` (`user_id`),
ADD KEY `orders_payment_id_foreign` (`payment_id`);
--
-- Indexes for table `password_resets`
--
ALTER TABLE `password_resets`
ADD KEY `password_resets_email_index` (`email`);
--
-- Indexes for table `payments`
--
ALTER TABLE `payments`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `payments_short_name_unique` (`short_name`);
--
-- Indexes for table `products`
--
ALTER TABLE `products`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `product_images`
--
ALTER TABLE `product_images`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `settings`
--
ALTER TABLE `settings`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `users_username_unique` (`username`),
ADD UNIQUE KEY `users_phone_no_unique` (`phone_no`),
ADD UNIQUE KEY `users_email_unique` (`email`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `admins`
--
ALTER TABLE `admins`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `brands`
--
ALTER TABLE `brands`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT for table `carts`
--
ALTER TABLE `carts`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=38;
--
-- AUTO_INCREMENT for table `categories`
--
ALTER TABLE `categories`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;
--
-- AUTO_INCREMENT for table `districts`
--
ALTER TABLE `districts`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `divisions`
--
ALTER TABLE `divisions`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `featureds`
--
ALTER TABLE `featureds`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `payments`
--
ALTER TABLE `payments`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
--
-- AUTO_INCREMENT for table `product_images`
--
ALTER TABLE `product_images`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26;
--
-- AUTO_INCREMENT for table `settings`
--
ALTER TABLE `settings`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `carts`
--
ALTER TABLE `carts`
ADD CONSTRAINT `carts_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `carts_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `carts_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `orders`
--
ALTER TABLE `orders`
ADD CONSTRAINT `orders_payment_id_foreign` FOREIGN KEY (`payment_id`) REFERENCES `payments` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `orders_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
<reponame>faizanbashir/cz_hrm
-- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jun 17, 2016 at 05:44 AM
-- Server version: 10.1.10-MariaDB
-- PHP Version: 5.6.15
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `cz_hrm`
--
-- --------------------------------------------------------
--
-- Table structure for table `advance_pay_requests`
--
CREATE TABLE `advance_pay_requests` (
`id` int(10) UNSIGNED NOT NULL,
`employee_id` int(11) NOT NULL,
`request_description` text NOT NULL,
`amount_requested` int(11) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','approved','rejected','deleted') NOT NULL DEFAULT 'active',
`approved_by` int(11) DEFAULT NULL,
`rejected_by` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `advance_pay_requests`
--
INSERT INTO `advance_pay_requests` (`id`, `employee_id`, `request_description`, `amount_requested`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`, `approved_by`, `rejected_by`) VALUES
(1, 12, 'This is a Test Description, for the advance pay.', 5000, 2, '2016-03-16 09:00:47', 1, '2016-04-15 16:36:31', 'approved', 1, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `company_details`
--
CREATE TABLE `company_details` (
`id` int(11) NOT NULL,
`company_name` varchar(32) DEFAULT NULL,
`tag_line` varchar(64) DEFAULT NULL,
`logo` varchar(32) DEFAULT 'logo.png',
`website_url` varchar(64) DEFAULT NULL,
`about_company` varchar(512) DEFAULT NULL,
`email` varchar(64) DEFAULT NULL,
`contact_no` varchar(16) DEFAULT NULL,
`fax_no` varchar(16) DEFAULT NULL,
`country` varchar(32) DEFAULT NULL,
`state` varchar(32) DEFAULT NULL,
`city` varchar(32) DEFAULT NULL,
`address` varchar(128) DEFAULT NULL,
`created_by` int(11) DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `company_details`
--
INSERT INTO `company_details` (`id`, `company_name`, `tag_line`, `logo`, `website_url`, `about_company`, `email`, `contact_no`, `fax_no`, `country`, `state`, `city`, `address`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`) VALUES
(1, 'Insights Communications', 'We Provide Business Solutions', 'avatar_1.png', 'http://www.insightsdubai.com', 'This is a solution provider company.', 'contactinsightsdubai.com', '1234567890', '1231321231', 'Antigua and Barbuda', 'Saint George', 'Dubai', 'Ist Floor, Acdt. Complex', NULL, '2016-03-04 10:19:18', 1, '2016-05-28 14:34:19');
-- --------------------------------------------------------
--
-- Table structure for table `company_holidays`
--
CREATE TABLE `company_holidays` (
`id` int(11) NOT NULL,
`title` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
`description` text COLLATE utf8_unicode_ci,
`date` date NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'active'
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `company_holidays`
--
INSERT INTO `company_holidays` (`id`, `title`, `description`, `date`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 'rgth', 'gfthbcgn', '2016-05-25', 1, '2016-05-04 09:37:46', 1, '2016-05-06 20:42:06', 'deleted'),
(2, 'TEST12345', 'TESTHOLIDAY', '2016-05-03', 1, '2016-05-04 09:39:03', 1, '2016-05-19 15:33:09', 'active'),
(3, 'GAZETTED HOLIDAY test', 'TEST ', '2016-05-23', 1, '2016-05-06 11:41:53', 1, '2016-05-19 15:32:59', 'active'),
(4, 'TEsT hoLidaY', 'teSt', '2016-05-16', 1, '2016-05-09 04:40:34', 1, '2016-05-09 13:42:03', 'deleted'),
(5, 'test test test', 'test holiday', '2016-05-25', 1, '2016-05-19 06:33:29', 1, '2016-05-19 15:33:41', 'deleted');
-- --------------------------------------------------------
--
-- Table structure for table `company_letters`
--
CREATE TABLE `company_letters` (
`id` int(10) UNSIGNED NOT NULL,
`category_id` int(11) NOT NULL,
`recipient` int(11) NOT NULL,
`letter_subject` varchar(512) NOT NULL,
`letter_body` text NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `company_letters`
--
INSERT INTO `company_letters` (`id`, `category_id`, `recipient`, `letter_subject`, `letter_body`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 1, 15, 'teSt', 'Test', 1, '2016-04-22 19:58:26', NULL, NULL, 'active'),
(2, 1, 15, 'teSt', 'SSSSS', 1, '2016-04-23 17:49:20', NULL, NULL, 'active'),
(3, 1, 12, 'teSt', 'WWEWE', 1, '2016-04-23 17:49:49', NULL, NULL, 'active');
-- --------------------------------------------------------
--
-- Table structure for table `company_products`
--
CREATE TABLE `company_products` (
`id` int(11) NOT NULL,
`name` varchar(64) NOT NULL,
`short_description` mediumtext NOT NULL,
`long_description` text NOT NULL,
`price` varchar(32) NOT NULL,
`image` varchar(32) DEFAULT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `company_products`
--
INSERT INTO `company_products` (`id`, `name`, `short_description`, `long_description`, `price`, `image`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 'iPhone', 'iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone', 'iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone iPhone', '50,000 ', '', 1, '2016-04-27 08:00:00', 1, '2016-05-10 21:10:30', 'active'),
(2, 'perfume', 'perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume', 'perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume perfume', '1223', 'Chrysanthemum.jpg', 1, '2016-04-28 06:42:03', NULL, NULL, 'active'),
(3, 'laptop', 'gvkhlbol;', 'rdtruylhyxcfiuo', '1234', 'Hydrangeas.jpg', 1, '2016-04-28 06:51:22', NULL, NULL, 'active'),
(4, 'necklace', 'ERETRY', 'EWRETREYRYSWDSFDTGszdffgh', '1234', 'Jellyfish.jpg', 1, '2016-04-28 06:51:48', NULL, NULL, 'active'),
(5, 'diamond', 'wr4etyr5y', 'awrwetye5ftydhfj', '1234', 'Penguins.jpg', 1, '2016-04-28 06:52:11', NULL, NULL, 'active');
-- --------------------------------------------------------
--
-- Table structure for table `customized_signatures`
--
CREATE TABLE `customized_signatures` (
`id` int(11) NOT NULL,
`name` varchar(32) NOT NULL,
`designation` varchar(32) NOT NULL,
`email` varchar(32) NOT NULL,
`contact` varchar(16) NOT NULL,
`mobile` varchar(16) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `customized_signatures`
--
INSERT INTO `customized_signatures` (`id`, `name`, `designation`, `email`, `contact`, `mobile`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 'urfeena', 'developer', '<EMAIL>', '1234567890', '1234567890', 0, '2016-05-09 09:29:39', NULL, NULL, 'active'),
(2, 'xyz', 'artist', '<EMAIL>', '1234567890', '9898989765', 0, '2016-05-09 09:41:39', 1, '2016-05-10 03:27:41', 'deleted'),
(3, 'faizan', 'developer', '<EMAIL>', '1234567890', '9898989765', 0, '2016-05-10 04:58:31', 1, '2016-05-16 13:38:32', 'deleted'),
(4, 'esefdg', 'dfdgd', '<EMAIL>', '1234567890', '9898989765', 0, '2016-05-10 05:05:33', 1, '2016-05-10 14:05:40', 'deleted'),
(5, '<NAME>', 'QA and Server Manager', '<EMAIL>', 'bhjghjghj', 'hjyfgtrhgfhy', 0, '2016-05-16 04:36:33', NULL, NULL, 'active'),
(6, '[removed] alert("hello")', 'AAA', '<EMAIL>', '234234342', '13212', 0, '2016-05-16 04:49:01', 1, '2016-05-16 13:57:26', 'deleted'),
(7, '[removed] alert("hello")', 'aqdefwfre', '<EMAIL>', '3434646567567', '3443656678678', 0, '2016-05-16 04:51:20', 1, '2016-05-16 13:54:44', 'deleted'),
(8, '<h1> HI </h1>', 'AAA', '<EMAIL>', '9797048265', '3443656678678', 0, '2016-05-16 04:55:33', 1, '2016-05-16 13:55:59', 'deleted');
-- --------------------------------------------------------
--
-- Table structure for table `employees`
--
CREATE TABLE `employees` (
`id` int(11) NOT NULL,
`designation_id` int(11) NOT NULL,
`designation` varchar(32) NOT NULL,
`first_name` varchar(32) NOT NULL,
`last_name` varchar(32) NOT NULL,
`fathers_name` varchar(32) NOT NULL,
`dob` date NOT NULL,
`contact_no` varchar(16) NOT NULL,
`mobile_no` varchar(16) NOT NULL,
`user_name` varchar(32) NOT NULL,
`user_password` varchar(128) NOT NULL,
`email` varchar(32) NOT NULL,
`email_password` varchar(32) DEFAULT NULL,
`avatar` varchar(32) NOT NULL DEFAULT 'avatar.gif',
`country` varchar(32) NOT NULL,
`state` varchar(32) NOT NULL,
`city` varchar(32) NOT NULL,
`address` varchar(64) NOT NULL,
`pin` varchar(16) NOT NULL,
`certifications` varchar(128) NOT NULL,
`trainings` varchar(128) NOT NULL,
`doj` date NOT NULL,
`probation_period` varchar(32) NOT NULL,
`employee_note` varchar(512) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`link_value` bigint(20) DEFAULT NULL,
`status` enum('active','suspended','terminated','link_send','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employees`
--
INSERT INTO `employees` (`id`, `designation_id`, `designation`, `first_name`, `last_name`, `fathers_name`, `dob`, `contact_no`, `mobile_no`, `user_name`, `user_password`, `email`, `email_password`, `avatar`, `country`, `state`, `city`, `address`, `pin`, `certifications`, `trainings`, `doj`, `probation_period`, `employee_note`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `link_value`, `status`) VALUES
(1, 0, 'Admin', 'Shoaib', 'Mohmad', 'Father', '2010-10-13', '1231231231', '9596545092', 'admin', '202cb962ac59075b964b07152d234b70', '<EMAIL>', 'asd<PASSWORD>', 'avatar_1.JPG', 'India', 'Jammu and Kashmir', 'Srinagar', 'Zakura, Hazratbal', '190006', 'Test Certification1', 'Test Training1', '2016-03-01', '3', 'This is Admin of the Application', 0, '2016-03-04 05:28:34', 1, '2016-05-28 15:24:08', NULL, 'active'),
(6, 4, 'Reporting Officer', 'Shoaib', 'Mohmad', 'Father', '2016-03-24', '1231231231', '9596545092', 'shoaib', '202cb962ac59075b964b07152d234b70', '<EMAIL>', 'asd', 'avatar.gif', 'Armenia', 'Lorri', 'Dubai', 'Ist Floor, Acdt. Complex', '123', 'Certifications', 'Trainings', '2016-03-14', '2', 'This is a Test Employee note...', 1, '2016-03-04 12:30:23', 1, '2016-04-06 12:04:31', NULL, 'active'),
(12, 4, 'Reporting Officer', 'Hilal', 'Ahmad', 'Father', '2016-03-15', '1231231231', '9596545091', 'hilal', '202cb962ac59075b964b07152d234b70', '<EMAIL>', 'sad', 'avatar.gif', 'Bahrain', 'Madinat ''Isa', 'Dubai', 'Ist Floor, Acdt. Complex', '123123', 'Certifications', 'Trainings', '2016-03-01', '2', 'Asd', 1, '2016-03-05 09:08:10', 1, '2016-04-06 11:42:20', NULL, 'active'),
(13, 2, 'Project Manager', 'Ameera ', 'Ullah', '<NAME>', '2000-01-05', '1231231231', '971557501653', 'ameer', '202cb962ac59075b964b07152d234b70', '<EMAIL>', '123', 'avatar.gif', 'India', 'Jammu and Kashmir', 'Srinagar', 'Ist Floor Wani Comples', '190001', '', '', '2016-03-01', '', 'This is a Test Project Manager.', 1, '2016-03-18 05:58:51', 1, '2016-04-26 21:08:20', NULL, 'active'),
(14, 1, 'Team Leader', 'Nowsheen', 'yousuf', 'Mr. Yousuf', '1991-09-26', '959653282', '959653282', 'Nowsheen', '202cb962ac59075b964b07152d234b70', '<EMAIL>', '12345', 'avatar.gif', 'India', 'Jammu and Kashmir', 'SRINAGAR', 'JANDK', '190018', 'C#,ASP.NET,AI', '', '2016-01-03', '3', '', 1, '2016-04-21 06:41:11', 1, '2016-04-21 16:12:40', NULL, 'active'),
(15, 2, 'Project Manager', 'Hamza', 'Bilal', 'Mr. Bilal ', '1990-03-08', '9797048265', '9797048265', 'hamza', 'bc<PASSWORD>', '<EMAIL>', 'hamza12345', 'avatar.gif', 'India', 'Jammu and Kashmir', 'srinagar', 'jandk', '190008', 'java, whm, oracle', '', '2014-01-07', '7', '', 1, '2016-04-21 07:05:15', 15, '2016-04-25 20:55:25', NULL, 'active'),
(16, 4, 'Reporting Officer', 'JUNAiD', 'sHAfi', 'SHAfi', '1970-01-01', '9697123123', '9697123123', 'jUNAids', '202cb962ac59075b964b07152d234b70', '<EMAIL>', '123', 'avatar.gif', 'India', 'Jammu and Kashmir', 'sriNAGAr', 'jaNdk', '190018', '', '', '2016-04-19', '6', 'DFhDFd', 1, '2016-04-26 06:41:02', 1, '2016-04-26 15:46:33', NULL, 'active');
-- --------------------------------------------------------
--
-- Table structure for table `employee_assets`
--
CREATE TABLE `employee_assets` (
`id` int(11) NOT NULL,
`employee_id` int(11) NOT NULL,
`asset_name` varchar(32) NOT NULL,
`description` text NOT NULL,
`issued_on` date DEFAULT NULL,
`returned_on` date DEFAULT NULL,
`created_by` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('issued','returned','deleted') NOT NULL DEFAULT 'issued'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee_assets`
--
INSERT INTO `employee_assets` (`id`, `employee_id`, `asset_name`, `description`, `issued_on`, `returned_on`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 12, 'laptop', 'Dell laptop', '1970-01-01', '2016-03-23', 1, '2016-03-29 07:36:02', 1, '2016-04-25 19:26:32', 'deleted'),
(2, 13, 'iPhone', 'Apple Phones ', '2016-01-26', NULL, 1, '2016-03-29 09:38:40', 1, '2016-04-26 15:43:52', 'issued'),
(3, 12, 'Router', 'D-Link router', '2016-03-01', '1970-01-01', 1, '2016-03-29 10:23:38', 1, '2016-04-26 15:44:58', 'returned'),
(4, 6, 'xzbfx nc', 'dszbfdxhgv', '2016-03-21', NULL, 1, '2016-03-29 10:24:01', 1, '2016-03-29 10:29:18', 'deleted'),
(5, 15, 'modems1233333', 'MODEM123', '1970-01-01', NULL, 1, '2016-04-22 08:35:03', 1, '2016-04-22 17:35:19', 'issued'),
(6, 13, 'Router', 'D-Link', '2015-12-02', NULL, 1, '2016-04-25 10:27:01', 1, '2016-04-26 15:45:34', 'deleted');
-- --------------------------------------------------------
--
-- Table structure for table `employee_designations`
--
CREATE TABLE `employee_designations` (
`id` int(10) UNSIGNED NOT NULL,
`designation_title` varchar(128) NOT NULL,
`designation_description` varchar(512) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee_designations`
--
INSERT INTO `employee_designations` (`id`, `designation_title`, `designation_description`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 'Team Leader', 'Team Leader''s job is to Lead the Team.', 1, '2016-04-06 11:03:08', NULL, NULL, 'active'),
(2, 'Project Manager', 'Project Manager''s Job is to manage the Project.', 1, '2016-04-06 11:05:09', 1, '2016-04-21 17:31:35', 'active'),
(3, 'Line Manager', 'Line Manager''s Job is to view the Performance.', 1, '2016-04-06 11:05:59', 1, '2016-04-06 11:10:02', 'active'),
(4, 'Reporting Officer', 'Reporting Officer''s Job is to manage the Leads.', 1, '2016-04-06 11:06:33', NULL, NULL, 'active'),
(5, 'doctor123', 'doctor doctor doctor', 1, '2016-04-21 08:08:37', 1, '2016-04-21 17:09:14', 'deleted');
-- --------------------------------------------------------
--
-- Table structure for table `employee_evaluation`
--
CREATE TABLE `employee_evaluation` (
`id` int(10) UNSIGNED NOT NULL,
`question_id` int(11) NOT NULL,
`question_description` varchar(512) NOT NULL,
`employee_id` int(11) NOT NULL,
`employee_rating` int(11) NOT NULL,
`concerned_head_ratings` varchar(64) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee_evaluation`
--
INSERT INTO `employee_evaluation` (`id`, `question_id`, `question_description`, `employee_id`, `employee_rating`, `concerned_head_ratings`, `created_at`) VALUES
(1, 1, 'How do you rate your performance? \r\n \r\n', 6, 4, '12-8,13-7', '2015-12-31 18:30:00'),
(2, 2, 'You attitude towards work? \r\n \r\n', 6, 7, '12-8,13-7', '2015-12-31 18:30:00'),
(3, 3, 'Not been able to do? \r\n \r\n', 6, 3, '12-8,13-7', '2015-12-31 18:30:00'),
(4, 4, 'Multi tasking \r\n \r\n', 6, 5, '12-8,13-7', '2015-12-31 18:30:00'),
(5, 5, 'Taking Ownership \r\n \r\n', 6, 7, '12-8,13-7', '2015-12-31 18:30:00'),
(6, 6, 'Needed to be reminded \r\n \r\n', 6, 7, '12-8,13-7', '2015-12-31 18:30:00'),
(7, 7, 'Time management \r\n \r\n', 6, 4, '12-8,13-7', '2015-12-31 18:30:00'),
(8, 8, 'Job timely delivery \r\n \r\n', 6, 10, '12-8,13-7', '2015-12-31 18:30:00'),
(9, 9, 'Communication \r\n \r\n', 6, 6, '12-8,13-7', '2015-12-31 18:30:00'),
(10, 10, 'Skills \r\n', 6, 7, '12-8,13-7', '2015-12-31 18:30:00'),
(11, 11, 'Speed \r\n', 6, 6, '12-8,13-7', '2015-12-31 18:30:00'),
(12, 12, 'New skills \r\n \r\n', 6, 7, '12-8,13-7', '2015-12-31 18:30:00'),
(13, 13, 'Training Requirement \r\n \r\n', 6, 7, '12-8,13-7', '2015-12-31 18:30:00'),
(14, 14, 'Initiative to Learn \r\n \r\n', 6, 4, '12-8,13-7', '2015-12-31 18:30:00'),
(15, 15, 'Any Compliments from manager/Colleague? \r\n \r\n', 6, 9, '12-8,13-7', '2015-12-31 18:30:00'),
(16, 16, 'Good candidate for future of co \r\n \r\n', 6, 8, '12-8,13-7', '2015-12-31 18:30:00'),
(17, 17, 'Any thing we missed to appreciate you for? \r\n \r\n', 6, 9, '12-8,13-7', '2015-12-31 18:30:00'),
(18, 18, 'Any value addition to company? \r\n \r\n', 6, 10, '12-8,13-7', '2015-12-31 18:30:00'),
(19, 19, 'Where do you want to to see yourself in next 12 months? \r\n \r\n', 6, 6, '12-8,13-7', '2015-12-31 18:30:00'),
(20, 20, 'How do you plan to do it? \r\n \r\n', 6, 3, '12-8,13-7', '2015-12-31 18:30:00'),
(21, 21, 'How fair is company to you? \r\n \r\n', 6, 5, '12-8,13-7', '2015-12-31 18:30:00'),
(22, 22, 'What is one thing you want to change in company (except boss)? \r\n \r\n', 6, 8, '12-8,13-7', '2015-12-31 18:30:00'),
(23, 23, 'Attendance \r\n \r\n', 6, 7, '12-8,13-7', '2015-12-31 18:30:00'),
(24, 1, 'How do you rate your performance? \r\n \r\n', 6, 6, '12-8,13-7', '2016-04-11 10:55:31'),
(25, 2, 'You attitude towards work? \r\n \r\n', 6, 8, '12-8,13-7', '2016-04-11 10:55:31'),
(26, 3, 'Not been able to do? \r\n \r\n', 6, 7, '12-8,13-7', '2016-04-11 10:55:31'),
(27, 4, 'Multi tasking \r\n \r\n', 6, 6, '12-8,13-7', '2016-04-11 10:55:31'),
(28, 5, 'Taking Ownership \r\n \r\n', 6, 3, '12-8,13-7', '2016-04-11 10:55:31'),
(29, 6, 'Needed to be reminded \r\n \r\n', 6, 5, '12-8,13-7', '2016-04-11 10:55:31'),
(30, 7, 'Time management \r\n \r\n', 6, 4, '12-8,13-7', '2016-04-11 10:55:31'),
(31, 8, 'Job timely delivery \r\n \r\n', 6, 4, '12-8,13-7', '2016-04-11 10:55:31'),
(32, 9, 'Communication \r\n \r\n', 6, 9, '12-8,13-7', '2016-04-11 10:55:31'),
(33, 10, 'Skills \r\n', 6, 10, '12-8,13-7', '2016-04-11 10:55:31'),
(34, 11, 'Speed \r\n', 6, 4, '12-8,13-7', '2016-04-11 10:55:31'),
(35, 12, 'New skills \r\n \r\n', 6, 5, '12-8,13-7', '2016-04-11 10:55:31'),
(36, 13, 'Training Requirement \r\n \r\n', 6, 6, '12-8,13-7', '2016-04-11 10:55:31'),
(37, 14, 'Initiative to Learn \r\n \r\n', 6, 5, '12-8,13-7', '2016-04-11 10:55:31'),
(38, 15, 'Any Compliments from manager/Colleague? \r\n \r\n', 6, 10, '12-8,13-7', '2016-04-11 10:55:31'),
(39, 16, 'Good candidate for future of co \r\n \r\n', 6, 8, '12-8,13-7', '2016-04-11 10:55:31'),
(40, 17, 'Any thing we missed to appreciate you for? \r\n \r\n', 6, 6, '12-8,13-7', '2016-04-11 10:55:31'),
(41, 18, 'Any value addition to company? \r\n \r\n', 6, 4, '12-8,13-7', '2016-04-11 10:55:31'),
(42, 19, 'Where do you want to to see yourself in next 12 months? \r\n \r\n', 6, 10, '12-8,13-7', '2016-04-11 10:55:31'),
(43, 20, 'How do you plan to do it? \r\n \r\n', 6, 9, '12-8,13-7', '2016-04-11 10:55:31'),
(44, 21, 'How fair is company to you? \r\n \r\n', 6, 8, '12-8,13-7', '2016-04-11 10:55:31'),
(45, 22, 'What is one thing you want to change in company (except boss)? \r\n \r\n', 6, 6, '12-8,13-7', '2016-04-11 10:55:31'),
(46, 23, 'Attendance \r\n \r\n', 6, 4, '12-8,13-7', '2016-04-11 10:55:31'),
(47, 1, 'How do you rate your performance? \r\n \r\n', 12, 5, '13-8', '2016-04-12 15:18:38'),
(48, 2, 'You attitude towards work? \r\n \r\n', 12, 6, '13-8', '2016-04-12 15:18:38'),
(49, 3, 'Not been able to do? \r\n \r\n', 12, 8, '13-8', '2016-04-12 15:18:38'),
(50, 4, 'Multi tasking \r\n \r\n', 12, 7, '13-4', '2016-04-12 15:18:38'),
(51, 5, 'Taking Ownership \r\n \r\n', 12, 7, '13-5', '2016-04-12 15:18:38'),
(52, 6, 'Needed to be reminded \r\n \r\n', 12, 8, '13-1', '2016-04-12 15:18:38'),
(53, 7, 'Time management \r\n \r\n', 12, 8, '13-5', '2016-04-12 15:18:38'),
(54, 8, 'Job timely delivery \r\n \r\n', 12, 5, '13-6', '2016-04-12 15:18:38'),
(55, 9, 'Communication \r\n \r\n', 12, 7, '13-5', '2016-04-12 15:18:38'),
(56, 10, 'Skills \r\n', 12, 6, '13-7', '2016-04-12 15:18:38'),
(57, 11, 'Speed \r\n', 12, 8, '13-8', '2016-04-12 15:18:38'),
(58, 12, 'New skills \r\n \r\n', 12, 9, '13-9', '2016-04-12 15:18:38'),
(59, 13, 'Training Requirement \r\n \r\n', 12, 7, '13-7', '2016-04-12 15:18:38'),
(60, 14, 'Initiative to Learn \r\n \r\n', 12, 7, '13-7', '2016-04-12 15:18:38'),
(61, 15, 'Any Compliments from manager/Colleague? \r\n \r\n', 12, 9, '13-3', '2016-04-12 15:18:38'),
(62, 16, 'Good candidate for future of co \r\n \r\n', 12, 9, '13-6', '2016-04-12 15:18:38'),
(63, 17, 'Any thing we missed to appreciate you for? \r\n \r\n', 12, 7, '13-3', '2016-04-12 15:18:38'),
(64, 18, 'Any value addition to company? \r\n \r\n', 12, 8, '13-4', '2016-04-12 15:18:38'),
(65, 19, 'Where do you want to to see yourself in next 12 months? \r\n \r\n', 12, 8, '13-5', '2016-04-12 15:18:38'),
(66, 20, 'How do you plan to do it? \r\n \r\n', 12, 6, '13-2', '2016-04-12 15:18:38'),
(67, 21, 'How fair is company to you? \r\n \r\n', 12, 8, '13-3', '2016-04-12 15:18:38'),
(68, 22, 'What is one thing you want to change in company (except boss)? \r\n \r\n', 12, 6, '13-5', '2016-04-12 15:18:38'),
(69, 23, 'Attendance \r\n \r\n', 12, 6, '13-6', '2016-04-12 15:18:38');
-- --------------------------------------------------------
--
-- Table structure for table `employee_experience`
--
CREATE TABLE `employee_experience` (
`id` int(11) NOT NULL,
`employee_id` int(11) NOT NULL,
`designation` varchar(32) NOT NULL,
`employer` varchar(128) NOT NULL,
`duration_from` date NOT NULL,
`duration_to` date NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee_experience`
--
INSERT INTO `employee_experience` (`id`, `employee_id`, `designation`, `employer`, `duration_from`, `duration_to`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(7, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-05 09:08:11', 1, '2016-04-06 11:42:20', 'deleted'),
(8, 12, 'Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-03-05 09:08:11', 1, '2016-04-06 11:42:20', 'deleted'),
(12, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-05 10:45:17', 1, '2016-04-06 11:42:20', 'deleted'),
(13, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-05 10:46:41', 1, '2016-04-06 11:42:20', 'deleted'),
(14, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-05 10:47:14', 1, '2016-04-06 11:42:20', 'deleted'),
(15, 12, 'Sr Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-03-05 10:47:14', 1, '2016-04-06 11:42:20', 'deleted'),
(16, 6, 'Developer', 'SDF', '2016-03-01', '2016-03-10', 1, '2016-03-05 11:15:50', 1, '2016-04-06 12:04:31', 'deleted'),
(17, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-07 11:14:11', 1, '2016-04-06 11:42:20', 'deleted'),
(18, 12, 'Sr Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-03-07 11:14:11', 1, '2016-04-06 11:42:20', 'deleted'),
(19, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-07 12:27:04', 1, '2016-04-06 11:42:20', 'deleted'),
(20, 12, 'Sr Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-03-07 12:27:04', 1, '2016-04-06 11:42:20', 'deleted'),
(21, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-07 12:30:38', 1, '2016-04-06 11:42:20', 'deleted'),
(22, 12, 'Sr Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-03-07 12:30:38', 1, '2016-04-06 11:42:20', 'deleted'),
(23, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-08 06:40:25', 1, '2016-04-06 11:42:20', 'deleted'),
(24, 12, 'Sr Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-03-08 06:40:25', 1, '2016-04-06 11:42:20', 'deleted'),
(25, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-08 06:41:48', 1, '2016-04-06 11:42:20', 'deleted'),
(26, 12, 'Sr Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-03-08 06:41:48', 1, '2016-04-06 11:42:20', 'deleted'),
(27, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-14 07:33:53', 1, '2016-04-06 11:42:20', 'deleted'),
(28, 12, 'Sr Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-03-14 07:33:53', 1, '2016-04-06 11:42:20', 'deleted'),
(29, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-14 07:35:19', 1, '2016-04-06 11:42:20', 'deleted'),
(30, 12, 'Sr Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-03-14 07:35:19', 1, '2016-04-06 11:42:20', 'deleted'),
(31, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-14 07:35:58', 1, '2016-04-06 11:42:20', 'deleted'),
(32, 12, 'Sr Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-03-14 07:35:58', 1, '2016-04-06 11:42:20', 'deleted'),
(33, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-14 07:48:35', 1, '2016-04-06 11:42:20', 'deleted'),
(34, 12, 'Sr Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-03-14 07:48:35', 1, '2016-04-06 11:42:20', 'deleted'),
(35, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-14 07:49:51', 1, '2016-04-06 11:42:20', 'deleted'),
(36, 12, 'Sr Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-03-14 07:49:51', 1, '2016-04-06 11:42:20', 'deleted'),
(37, 6, 'Developer', 'SDF', '2016-03-01', '2016-03-10', 1, '2016-03-14 08:04:04', 1, '2016-04-06 12:04:31', 'deleted'),
(38, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-03-16 05:24:15', 1, '2016-04-06 11:42:20', 'deleted'),
(39, 12, 'Sr Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-03-16 05:24:15', 1, '2016-04-06 11:42:20', 'deleted'),
(40, 12, 'Developer', 'ABC', '2016-03-10', '2016-03-12', 1, '2016-04-06 11:42:20', NULL, NULL, 'active'),
(41, 12, 'Sr Developer', 'DEF', '2016-03-30', '2016-03-31', 1, '2016-04-06 11:42:20', NULL, NULL, 'active'),
(42, 6, 'Developer', 'SDF', '2016-03-01', '2016-03-10', 1, '2016-04-06 12:04:31', NULL, NULL, 'active'),
(43, 14, 'SEO ANALYST', 'INSIGHTSDUBAI', '2015-04-21', '1970-01-01', 1, '2016-04-21 06:41:11', 1, '2016-04-21 16:12:40', 'deleted'),
(44, 14, 'SEO ANALYST', 'INSIGHTSDUBAI', '2015-04-21', '1970-01-01', 1, '2016-04-21 06:59:30', 1, '2016-04-21 16:12:40', 'deleted'),
(45, 15, 'Server handler and testing', 'insightsdubai', '2015-08-02', '1970-01-01', 1, '2016-04-21 07:05:15', 1, '2016-04-21 16:21:02', 'deleted'),
(46, 15, '', '', '1970-01-01', '1970-01-01', 1, '2016-04-21 07:05:15', 1, '2016-04-21 16:21:02', 'deleted'),
(47, 14, 'SEO ANALYST', 'INSIGHTSDUBAI', '2015-04-21', '1970-01-01', 1, '2016-04-21 07:12:40', NULL, NULL, 'active'),
(48, 15, 'Server handler and testing', 'insightsdubai', '2015-08-02', '1970-01-01', 1, '2016-04-21 07:21:02', NULL, NULL, 'active'),
(49, 15, '', '', '1970-01-01', '1970-01-01', 1, '2016-04-21 07:21:02', NULL, NULL, 'active'),
(50, 16, 'seO', 'IS', '2016-04-04', '2016-04-20', 1, '2016-04-26 06:41:02', 1, '2016-04-26 15:46:33', 'deleted'),
(51, 16, '', '', '1970-01-01', '1970-01-01', 1, '2016-04-26 06:41:02', 1, '2016-04-26 15:46:33', 'deleted'),
(52, 16, 'seO', 'IS', '2016-04-04', '2016-04-20', 1, '2016-04-26 06:46:33', NULL, NULL, 'active'),
(53, 16, '', '', '1970-01-01', '1970-01-01', 1, '2016-04-26 06:46:33', NULL, NULL, 'active');
-- --------------------------------------------------------
--
-- Table structure for table `employee_files`
--
CREATE TABLE `employee_files` (
`id` int(11) NOT NULL,
`employee_id` int(11) NOT NULL,
`file_name_url` varchar(32) NOT NULL,
`file_name` varchar(64) NOT NULL,
`file_description` varchar(256) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee_files`
--
INSERT INTO `employee_files` (`id`, `employee_id`, `file_name_url`, `file_name`, `file_description`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(3, 12, '12_1.xlsx', 'Experience Certificate', 'This is the Experience Certificate of Hilal Ahmad', 1, '2016-03-05 09:08:10', NULL, NULL, 'active'),
(4, 12, '12_2.pdf', 'Sde', 'asdasd', 1, '2016-03-05 09:08:11', 1, '2016-03-05 10:33:42', 'active'),
(5, 14, '14_1.docx', 'CV', 'RESUME', 1, '2016-04-21 06:41:11', NULL, NULL, 'active'),
(6, 15, '15_1.docx', 'cv', 'resume', 1, '2016-04-21 07:05:15', NULL, NULL, 'active'),
(7, 16, '16_1.', 'RYtry', 'FyTR', 1, '2016-04-26 06:41:02', NULL, NULL, 'active'),
(8, 16, '16_2.', '', '', 1, '2016-04-26 06:41:02', NULL, NULL, 'active');
-- --------------------------------------------------------
--
-- Table structure for table `employee_leaves`
--
CREATE TABLE `employee_leaves` (
`id` int(11) NOT NULL,
`employee_id` int(11) NOT NULL,
`leave_id` int(11) NOT NULL,
`leave_from` date DEFAULT NULL,
`leave_to` date DEFAULT NULL,
`day` date DEFAULT NULL,
`subject` text NOT NULL,
`leave_description` text NOT NULL,
`approved_by` int(11) DEFAULT NULL,
`rejected_by` int(11) DEFAULT NULL,
`created_by` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','approved','rejected','deleted') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee_leaves`
--
INSERT INTO `employee_leaves` (`id`, `employee_id`, `leave_id`, `leave_from`, `leave_to`, `day`, `subject`, `leave_description`, `approved_by`, `rejected_by`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 12, 2, '2016-03-30', '2016-04-01', '2016-03-30', 'Wedding', 'marriage ceremony of my sister', 1, NULL, 1, '2016-03-23 07:01:36', 1, '2016-05-11 07:37:57', 'approved'),
(2, 6, 1, '2016-03-30', '2016-04-10', NULL, 'hello', 'hello', 13, NULL, 1, '2016-03-23 09:23:31', 13, '2016-04-13 17:11:27', 'approved'),
(3, 12, 1, NULL, NULL, '2016-05-11', 'wafesg', 'awfergth', 1, NULL, 1, '2016-03-23 09:25:20', 1, '2016-05-11 07:37:49', 'approved'),
(4, 1, 1, '2016-03-20', '2016-04-25', NULL, 'dSEGrdh', 'qwrgahe', NULL, 1, 1, '2016-03-23 09:29:12', 1, '2016-04-25 08:42:37', 'deleted'),
(5, 1, 3, '2016-03-21', '2016-03-23', NULL, 'This is a Test', 'This is a Test Description.', NULL, NULL, 1, '2016-03-23 09:30:29', 6, '2016-03-28 11:30:08', 'active'),
(6, 1, 2, '2016-03-21', '2016-04-01', NULL, 'new', 'new', NULL, NULL, 1, '2016-03-23 10:20:43', 1, '2016-03-23 11:03:14', 'deleted'),
(7, 6, 3, '2016-04-14', '2016-04-15', NULL, 'Sick Leave Request', 'Please give me the Leave.', 13, NULL, 6, '2016-04-08 07:35:46', 13, '2016-04-13 17:08:35', 'approved'),
(8, 6, 3, '2016-04-14', '2016-04-15', NULL, 'Sick Leave Request', 'Please give me the Leave.', 13, NULL, 6, '2016-04-08 07:35:59', 13, '2016-04-13 16:26:41', 'approved'),
(9, 6, 2, '2016-04-19', '2016-04-20', NULL, 'This is a Test', 'asd', 13, NULL, 6, '2016-04-08 07:39:18', 13, '2016-04-13 16:22:53', 'approved'),
(10, 6, 3, '2016-04-06', '2016-04-07', NULL, 'Subjecy', 'This is a Test', NULL, NULL, 6, '2016-04-15 16:57:17', NULL, NULL, 'active'),
(11, 6, 3, '2016-04-06', '2016-04-07', NULL, 'Subjecy', 'This is a Test', 1, NULL, 6, '2016-04-15 16:58:10', 1, '2016-05-26 21:46:40', 'approved'),
(12, 6, 3, '2016-04-06', '2016-04-07', NULL, 'Subjecy', 'This is a Test', NULL, NULL, 6, '2016-04-15 16:59:59', NULL, NULL, 'active'),
(13, 13, 1, '2016-03-10', '2016-03-21', '2016-05-02', 'fcgjhmbb ', 'hello full day', NULL, NULL, 13, '2016-05-11 06:58:44', 1, '2016-05-11 07:14:35', 'active'),
(14, 13, 6, '2016-05-10', '2016-05-10', '1970-01-01', 'gvdjdskj,', 'wederfrtgrt', 1, NULL, 13, '2016-05-11 10:02:48', 1, '2016-05-11 10:11:40', 'approved'),
(15, 13, 6, '2016-05-02', '2016-05-02', '1970-01-01', 'hbjb,m', 'dcdcfv', 1, NULL, 13, '2016-05-11 10:10:09', 1, '2016-05-11 10:11:07', 'approved'),
(16, 13, 6, '2016-05-01', '2016-05-01', '1970-01-01', 'work', 'test', NULL, 1, 13, '2016-05-19 17:08:41', 1, '2016-05-19 17:11:01', 'deleted'),
(17, 13, 3, '2016-05-02', '2016-05-04', '1970-01-01', 'test', 'test', 1, NULL, 13, '2016-05-19 17:11:51', 1, '2016-05-19 17:12:58', 'deleted'),
(18, 13, 2, '2016-05-16', '2016-05-18', '1970-01-01', 'test', 'test', NULL, NULL, 13, '2016-05-19 17:13:24', NULL, NULL, 'active'),
(19, 13, 2, '2016-05-12', '2016-05-13', '1970-01-01', 'test', 'test', NULL, NULL, 13, '2016-05-19 17:15:14', NULL, NULL, 'active'),
(20, 13, 2, '2016-05-02', '2016-05-03', '1970-01-01', 'test', 'test', NULL, NULL, 13, '2016-05-19 17:16:59', NULL, NULL, 'active');
-- --------------------------------------------------------
--
-- Table structure for table `employee_login`
--
CREATE TABLE `employee_login` (
`id` int(11) NOT NULL,
`employee_id` int(11) NOT NULL,
`logged_in_at` time NOT NULL,
`logged_out_at` time DEFAULT NULL,
`created_by` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee_login`
--
INSERT INTO `employee_login` (`id`, `employee_id`, `logged_in_at`, `logged_out_at`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(55, 1, '05:30:00', '07:15:00', 1, '2016-03-23 08:07:13', 6, '2016-03-28 10:19:35', 'active'),
(56, 12, '04:20:00', '09:26:00', 6, '2016-03-22 10:23:22', NULL, NULL, 'active'),
(57, 12, '09:00:00', NULL, 12, '2016-03-22 10:26:10', 1, '2016-03-22 11:07:26', 'active'),
(58, 12, '11:17:58', '05:30:00', 1, '2016-03-23 05:47:58', 6, '2016-03-28 10:23:38', 'active'),
(59, 6, '10:58:16', NULL, 6, '2016-04-07 05:28:16', NULL, NULL, 'active'),
(60, 1, '14:51:28', '14:51:45', 1, '2016-04-07 09:21:28', 1, '2016-04-07 09:21:45', 'active'),
(61, 6, '15:06:56', '15:06:58', 6, '2016-04-07 09:36:56', 6, '2016-04-07 09:36:58', 'active'),
(62, 6, '16:41:00', '16:41:02', 6, '2016-04-07 11:11:00', 6, '2016-04-07 11:11:02', 'active'),
(65, 6, '10:03:00', '15:03:05', 6, '2016-04-08 09:33:00', 6, '2016-04-08 09:33:05', 'active'),
(66, 1, '15:45:11', NULL, 1, '2016-04-09 10:15:11', NULL, NULL, 'active'),
(67, 6, '16:13:12', '16:13:21', 6, '2016-04-09 10:43:12', 6, '2016-04-09 10:43:21', 'active'),
(68, 6, '11:35:14', NULL, 6, '2016-04-11 06:05:14', NULL, NULL, 'active'),
(69, 6, '21:44:20', '21:44:30', 6, '2016-04-15 16:14:20', 6, '2016-04-15 16:14:30', 'active'),
(70, 6, '00:00:00', '00:00:00', 6, '2016-04-22 07:10:12', 1, '2016-04-22 18:03:59', 'active'),
(71, 6, '11:10:12', '13:00:00', 6, '2016-04-22 07:10:12', 1, '2016-04-22 17:52:39', 'active'),
(72, 12, '11:14:27', '11:18:13', 12, '2016-04-22 07:14:27', 12, '2016-04-22 16:18:13', 'active'),
(73, 13, '12:58:17', '12:58:45', 13, '2016-04-22 08:58:17', 1, '2016-04-22 18:00:41', 'active'),
(74, 15, '09:58:00', '10:25:00', 15, '2016-04-23 05:58:00', 1, '2016-04-23 15:00:04', 'active'),
(75, 14, '15:07:06', NULL, 14, '2016-04-23 11:07:06', NULL, NULL, 'active'),
(76, 13, '08:57:09', NULL, 13, '2016-04-26 04:57:09', NULL, NULL, 'active'),
(77, 1, '09:00:00', '18:00:00', 1, '2016-05-02 05:00:00', NULL, NULL, 'active'),
(78, 1, '09:00:00', '18:00:00', 1, '2016-05-02 05:00:00', NULL, NULL, 'active'),
(79, 1, '09:00:00', '18:00:00', 1, '2016-03-10 06:00:00', NULL, NULL, 'active'),
(80, 13, '09:23:09', NULL, 13, '2016-05-09 05:23:09', NULL, NULL, 'active'),
(81, 6, '15:26:07', NULL, 6, '2016-05-26 09:56:07', NULL, NULL, 'active');
-- --------------------------------------------------------
--
-- Table structure for table `employee_performance_reports`
--
CREATE TABLE `employee_performance_reports` (
`id` int(11) NOT NULL,
`employee_id` int(11) NOT NULL,
`submitted_by` int(11) NOT NULL,
`submitted_to` int(11) NOT NULL,
`submitted_on` date NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee_performance_reports`
--
INSERT INTO `employee_performance_reports` (`id`, `employee_id`, `submitted_by`, `submitted_to`, `submitted_on`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(5, 15, 12, 1, '2016-05-02', 1, '2016-05-06 06:31:02', 1, '2016-05-07 21:51:46', 'deleted'),
(7, 13, 12, 1, '2016-05-02', 1, '2016-05-06 09:12:51', 1, '2016-05-07 07:51:55', 'deleted'),
(9, 13, 15, 1, '2016-05-15', 1, '2016-05-06 10:55:32', 1, '2016-05-07 07:40:53', 'deleted'),
(10, 6, 12, 1, '2016-05-01', 1, '2016-05-06 12:02:12', 1, '2016-05-07 07:48:43', 'deleted'),
(11, 12, 14, 1, '2016-05-01', 1, '2016-05-06 12:03:04', 1, '2016-05-07 07:50:47', 'deleted'),
(14, 14, 15, 1, '2016-05-07', 1, '2016-05-07 08:59:41', 1, '2016-05-07 07:39:27', 'deleted'),
(15, 14, 15, 1, '2016-05-07', 1, '2016-05-07 09:00:46', 1, '2016-05-07 07:39:46', 'deleted'),
(16, 14, 15, 1, '2016-05-07', 1, '2016-05-07 09:01:30', 1, '2016-05-07 07:46:52', 'deleted'),
(18, 16, 14, 1, '2016-05-01', 1, '2016-05-07 12:47:31', 1, '2016-05-09 12:49:36', 'deleted'),
(19, 13, 12, 1, '2016-05-02', 1, '2016-05-07 12:52:47', NULL, NULL, 'active'),
(20, 16, 14, 1, '2016-05-20', 1, '2016-05-09 03:48:01', NULL, NULL, 'active'),
(21, 6, 13, 1, '2016-05-16', 1, '2016-05-09 03:50:20', NULL, NULL, 'active');
-- --------------------------------------------------------
--
-- Table structure for table `employee_qualification`
--
CREATE TABLE `employee_qualification` (
`id` int(11) NOT NULL,
`employee_id` int(11) NOT NULL,
`qualification` varchar(64) NOT NULL,
`authority` varchar(64) NOT NULL,
`percentage` int(11) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee_qualification`
--
INSERT INTO `employee_qualification` (`id`, `employee_id`, `qualification`, `authority`, `percentage`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 12, '1', 'JKBOSE', 67, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(2, 12, '10th', 'JKBOSE', 67, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(3, 12, '12th', 'JKBOSE', 45, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(4, 12, '10th', 'JKBOSE', 67, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(5, 12, '12th', 'JKBOSE', 45, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(6, 12, '10th', 'JKBOSE', 67, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(7, 12, '12th', 'JKBOSE', 45, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(8, 12, '10th', 'JKBOSE', 67, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(9, 12, '12th', 'JKBOSE', 45, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(10, 12, '10th', 'JKBOSE', 67, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(11, 12, '12th', 'JKBOSE', 45, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(12, 12, '10th', 'JKBOSE', 67, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(13, 12, '12th', 'JKBOSE', 45, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(14, 12, '10th', 'JKBOSE', 67, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(15, 12, '12th', 'JKBOSE', 45, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(16, 12, '10th', 'JKBOSE', 67, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(17, 12, '12th', 'JKBOSE', 45, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(18, 12, '10th', 'JKBOSE', 67, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(19, 12, '12th', 'JKBOSE', 45, 1, '2016-04-06 11:42:20', 1, '2016-04-06 11:42:20', 'deleted'),
(20, 12, '10th', 'JKBOSE', 67, 1, '2016-04-06 11:42:20', NULL, NULL, 'active'),
(21, 12, '12th', 'JKBOSE', 45, 1, '2016-04-06 11:42:20', NULL, NULL, 'active'),
(22, 14, 'B.TECH', 'IUST', 90, 1, '2016-04-21 07:12:40', 1, '2016-04-21 16:12:40', 'deleted'),
(23, 14, '', '', 0, 1, '2016-04-21 07:12:40', 1, '2016-04-21 16:12:40', 'deleted'),
(24, 14, 'B.TECH', 'IUST', 90, 1, '2016-04-21 07:12:40', 1, '2016-04-21 16:12:40', 'deleted'),
(25, 14, '', '', 0, 1, '2016-04-21 07:12:40', 1, '2016-04-21 16:12:40', 'deleted'),
(26, 15, 'B.TECH', 'IUST', 90, 1, '2016-04-21 07:21:02', 1, '2016-04-21 16:21:02', 'deleted'),
(27, 15, '', '', 0, 1, '2016-04-21 07:21:02', 1, '2016-04-21 16:21:02', 'deleted'),
(28, 14, 'B.TECH', 'IUST', 90, 1, '2016-04-21 07:12:40', NULL, NULL, 'active'),
(29, 14, '', '', 0, 1, '2016-04-21 07:12:40', NULL, NULL, 'active'),
(30, 15, 'B.TECH', 'IUST', 90, 1, '2016-04-21 07:21:02', NULL, NULL, 'active'),
(31, 15, '', '', 0, 1, '2016-04-21 07:21:02', NULL, NULL, 'active'),
(32, 16, 'bcA', 'kU', 70, 1, '2016-04-26 06:46:33', 1, '2016-04-26 15:46:33', 'deleted'),
(33, 16, '', '', 0, 1, '2016-04-26 06:46:33', 1, '2016-04-26 15:46:33', 'deleted'),
(34, 16, 'bcA', 'kU', 70, 1, '2016-04-26 06:46:33', NULL, NULL, 'active'),
(35, 16, '', '', 0, 1, '2016-04-26 06:46:33', NULL, NULL, 'active');
-- --------------------------------------------------------
--
-- Table structure for table `employee_salary`
--
CREATE TABLE `employee_salary` (
`id` int(10) UNSIGNED NOT NULL,
`employee_id` int(11) NOT NULL,
`basic_salary` int(11) NOT NULL,
`house_allowance` int(11) NOT NULL,
`travelling_allowance` int(11) NOT NULL,
`other_allowance` int(11) NOT NULL,
`salary` int(11) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee_salary`
--
INSERT INTO `employee_salary` (`id`, `employee_id`, `basic_salary`, `house_allowance`, `travelling_allowance`, `other_allowance`, `salary`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 12, 2000, 1000, 500, 1000, 4500, 1, '2016-03-14 07:33:53', 1, '2016-03-14 07:49:51', 'deleted'),
(5, 12, 2000, 1000, 500, 1000, 4500, 1, '2016-03-14 07:49:51', 1, '2016-03-14 11:22:21', 'deleted'),
(6, 6, 2000, 2000, 1000, 1000, 6000, 1, '2016-03-14 08:04:04', NULL, NULL, 'active'),
(7, 12, 2000, 1000, 1000, 1000, 5000, 1, '2016-03-14 11:22:21', NULL, NULL, 'active'),
(8, 13, 2000, 1000, 1000, 1000, 5000, 1, '2016-03-19 06:29:15', NULL, NULL, 'active'),
(9, 14, 10, 2000, 3000, 1500, 34000, 1, '2016-04-21 06:41:11', NULL, NULL, 'active'),
(10, 15, 15000, 2000, 2000, 2000, 50, 1, '2016-04-21 07:05:15', NULL, NULL, 'active'),
(11, 16, 56546456, 46456, 546546, 546546, 546546, 1, '2016-04-26 06:41:02', NULL, NULL, 'active');
-- --------------------------------------------------------
--
-- Table structure for table `employee_teams`
--
CREATE TABLE `employee_teams` (
`id` int(10) UNSIGNED NOT NULL,
`team_name` varchar(64) NOT NULL,
`team_leader` int(11) NOT NULL,
`team_members` varchar(128) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=big5;
--
-- Dumping data for table `employee_teams`
--
INSERT INTO `employee_teams` (`id`, `team_name`, `team_leader`, `team_members`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 'Developers', 6, '13', 74, '2016-05-17 06:46:25', 1, '2016-05-17 08:33:09', 'active'),
(2, 'Designers', 12, '15,14', 1, '2016-05-17 10:03:39', NULL, NULL, 'active'),
(3, 'Programmers', 6, '12,16', 1, '2016-05-19 08:34:37', 1, '2016-05-19 17:57:54', 'deleted');
-- --------------------------------------------------------
--
-- Table structure for table `late_sitting`
--
CREATE TABLE `late_sitting` (
`id` int(11) NOT NULL,
`employee_id` int(11) NOT NULL,
`date` date NOT NULL,
`hours` int(11) NOT NULL,
`created_by` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`approved_by` int(11) DEFAULT NULL,
`rejected_by` int(11) DEFAULT NULL,
`status` enum('active','rejected','approved','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `late_sitting`
--
INSERT INTO `late_sitting` (`id`, `employee_id`, `date`, `hours`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `approved_by`, `rejected_by`, `status`) VALUES
(1, 1, '2016-03-23', 3, 1, '2016-03-25 10:44:22', 6, '2016-03-28 10:43:19', 1, NULL, 'deleted'),
(2, 1, '2016-03-09', 3, 1, '2016-03-25 10:46:42', 1, '2016-03-25 11:36:32', NULL, 1, 'deleted'),
(3, 1, '2016-03-18', 2, 1, '2016-03-25 10:47:59', 1, '2016-04-22 18:14:11', NULL, 1, 'deleted'),
(4, 12, '2016-03-15', 2, 12, '2016-03-25 11:03:49', 1, '2016-03-25 11:36:39', NULL, 1, 'deleted'),
(5, 1, '2016-03-22', 4, 1, '2016-03-25 11:06:05', 1, '2016-03-26 05:24:38', NULL, 1, 'deleted'),
(6, 1, '2016-03-30', 3, 1, '2016-03-25 11:37:18', 1, '2016-03-26 05:24:34', NULL, 1, 'deleted'),
(7, 1, '2016-03-16', 3, 1, '2016-03-26 05:24:23', 6, '2016-03-28 10:43:10', 6, NULL, 'approved'),
(8, 1, '2016-03-01', 7, 1, '2016-03-26 05:43:26', 1, '2016-04-26 15:50:39', NULL, NULL, 'active'),
(9, 6, '2016-03-18', 5, 6, '2016-03-28 10:45:45', 1, '2016-04-22 18:31:15', 1, NULL, 'deleted');
-- --------------------------------------------------------
--
-- Table structure for table `leaves`
--
CREATE TABLE `leaves` (
`id` int(10) UNSIGNED NOT NULL,
`leave_type` enum('full_day','half_day') NOT NULL DEFAULT 'full_day',
`leave_name` varchar(128) NOT NULL,
`leave_description` varchar(1024) NOT NULL,
`yearly_leaves` int(11) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `leaves`
--
INSERT INTO `leaves` (`id`, `leave_type`, `leave_name`, `leave_description`, `yearly_leaves`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 'full_day', 'Earned Leave or Privilege Leave', 'Employees earn as they work for an organisation for a specified number of days.', 12, 1, '2016-03-16 05:25:36', 1, '2016-03-16 10:38:26', 'active'),
(2, 'full_day', 'Casual Leave', 'Granted for short durations and can ordinarily be taken with prior information to the employer except in cases when informing the employer is not possible.', 10, 1, '2016-03-16 05:25:59', 1, '2016-03-16 05:41:03', 'active'),
(3, 'full_day', 'Sick Leave or Medical Leave', 'An employee can call in sick if he is not in a state to come to office for work.', 8, 1, '2016-03-16 05:31:20', 1, '2016-03-17 05:17:33', 'active'),
(6, 'half_day', 'Half Day', 'This is a half day leave', 6, 1, '2016-05-11 07:55:52', NULL, NULL, 'active');
-- --------------------------------------------------------
--
-- Table structure for table `letter_categories`
--
CREATE TABLE `letter_categories` (
`id` int(10) UNSIGNED NOT NULL,
`category_title` varchar(128) NOT NULL,
`category_description` varchar(1024) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `letter_categories`
--
INSERT INTO `letter_categories` (`id`, `category_title`, `category_description`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 'Appointment Letter', 'This is an Appointment Letter.', 1, '2016-04-19 08:43:42', 1, '2016-04-23 16:39:50', 'active'),
(2, 'Industry tour', 'This is a test message', 1, '2016-04-23 16:40:50', 1, '2016-04-23 16:41:23', 'deleted'),
(3, 'TEST LETTER', 'GFGDRS', 1, '2016-04-23 17:30:23', 1, '2016-04-23 17:47:02', 'deleted'),
(4, 'Offer Letter', 'offer letter offer letter ', 1, '2016-04-26 18:06:38', 1, '2016-04-26 18:06:55', 'active');
-- --------------------------------------------------------
--
-- Table structure for table `loan_requests`
--
CREATE TABLE `loan_requests` (
`id` int(10) UNSIGNED NOT NULL,
`employee_id` int(11) NOT NULL,
`loan_description` text NOT NULL,
`loan_amount` int(11) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','approved','rejected','deleted') NOT NULL DEFAULT 'active',
`approved_by` int(11) DEFAULT NULL,
`rejected_by` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `loan_requests`
--
INSERT INTO `loan_requests` (`id`, `employee_id`, `loan_description`, `loan_amount`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`, `approved_by`, `rejected_by`) VALUES
(1, 12, 'Sanction the Loan ASAP.', 45000, 12, '2016-03-16 10:27:35', 1, '2016-05-23 03:07:15', 'rejected', NULL, 1),
(2, 0, 'SdSwew', 1000000, 6, '2016-04-22 20:01:58', 1, '2016-04-23 18:22:24', 'deleted', NULL, NULL),
(3, 0, 'tesT loan', 50, 13, '2016-05-19 17:25:51', 1, '2016-05-26 22:14:51', 'deleted', NULL, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `miss_attendance`
--
CREATE TABLE `miss_attendance` (
`id` int(11) NOT NULL,
`employee_id` int(11) NOT NULL,
`date` date NOT NULL,
`missed` enum('time-in','time-out','both') NOT NULL,
`created_by` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`approved_by` int(11) DEFAULT NULL,
`rejected_by` int(11) DEFAULT NULL,
`status` enum('active','approved','rejected','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `miss_attendance`
--
INSERT INTO `miss_attendance` (`id`, `employee_id`, `date`, `missed`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `approved_by`, `rejected_by`, `status`) VALUES
(1, 12, '2016-03-28', 'time-in', 12, '2016-03-28 10:13:11', 1, '2016-04-22 18:23:49', NULL, 1, 'deleted'),
(2, 1, '2016-03-10', 'both', 1, '2016-03-28 10:28:11', 1, '2016-05-09 13:33:38', 1, NULL, 'approved'),
(3, 1, '2016-03-20', 'time-in', 1, '2016-03-28 10:48:38', 1, '2016-03-28 10:50:13', 1, NULL, 'deleted'),
(4, 1, '2016-03-30', 'time-in', 1, '2016-03-29 05:15:25', 1, '2016-05-09 13:31:26', 13, NULL, 'deleted'),
(5, 1, '2016-05-02', 'both', 1, '2016-05-04 11:17:24', 1, '2016-05-06 20:47:39', 1, NULL, 'deleted');
-- --------------------------------------------------------
--
-- Table structure for table `notifications`
--
CREATE TABLE `notifications` (
`id` int(10) UNSIGNED NOT NULL,
`sender_id` int(11) NOT NULL,
`reciever_id` int(11) NOT NULL,
`text` varchar(512) NOT NULL,
`url` varchar(128) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('unread','read','deleted') NOT NULL DEFAULT 'unread'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `notifications`
--
INSERT INTO `notifications` (`id`, `sender_id`, `reciever_id`, `text`, `url`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 1, 6, 'Your leave has been approved by Shoaib Mohmad.\r\n', 'user/personal/leaves', '2016-04-13 17:08:11', 6, '2016-04-13 17:08:11', 'read'),
(2, 13, 6, 'Your Leave has been approved by Ameer Ullah', 'user/personal/leaves', '2016-04-15 16:14:13', 6, '2016-04-15 16:14:13', 'read'),
(3, 13, 6, 'Your Leave request has been approved by Ameer Ullah [Project Manager.', 'user/personal/leaves', '2016-04-13 17:08:51', 6, '2016-04-13 17:08:51', 'read'),
(4, 13, 6, 'Your Leave request has been approved by Ameer Ullah [Project Manager].', 'user/personal/leaves', '2016-05-26 09:56:01', 6, '2016-05-26 09:56:01', 'read'),
(5, 1, 6, 'Your Extra Hours request has been approved by Shoaib Mohmad [Admin].', 'user/personal/leaves', '2016-04-15 16:18:13', NULL, NULL, 'unread'),
(6, 1, 6, 'Your Extra Hours request has been approved by Shoaib Mohmad [Admin].', 'user/personal/late_sitting', '2016-04-15 16:20:48', 6, '2016-04-15 16:20:48', 'read'),
(7, 1, 6, 'Your Off Day request has been approved by Shoaib Mohmad [Admin].', 'user/personal/off_days', '2016-04-15 16:24:06', NULL, NULL, 'unread'),
(8, 13, 1, 'Your Missing Time request has been approved by Ameer Ullah [Project Manager].', 'user/personal/missing_time', '2016-04-15 16:27:48', 1, '2016-04-15 16:27:48', 'read'),
(9, 1, 12, 'Your Training request has been approved by Shoaib Mohmad [Admin].', 'user/personal/missing_time', '2016-04-15 16:32:16', 12, '2016-04-15 16:32:16', 'read'),
(10, 1, 12, 'Your Pay request has been approved by Shoaib Mohmad [Admin].', 'user/personal/advance_pay', '2016-04-15 16:36:45', 12, '2016-04-15 16:36:45', 'read'),
(11, 6, 1, 'Leave has been requested by Shoaib Mohmad [Reporting Officer].', 'employees/leaves/employee_leaves', '2016-04-19 06:27:14', 1, '2016-04-19 06:27:14', 'read'),
(12, 6, 13, 'Leave has been requested by Shoaib Mohmad [Reporting Officer].', 'employees/leaves/employee_leaves', '2016-04-15 17:00:00', NULL, NULL, 'unread'),
(13, 1, 1, 'Your Extra Hours request has been deleted by Shoaib Mohmad [Admin].', 'user/personal/late_sitting', '2016-05-10 10:20:47', 1, '2016-05-10 19:20:47', 'read'),
(14, 1, 1, 'Your Off Day request has been deleted by Shoaib Mohmad [Admin].', 'user/personal/off_days', '2016-05-19 10:11:36', 1, '2016-05-19 19:11:36', 'read'),
(15, 1, 12, 'Your Missing Time request has been deleted by Shoaib Mohmad [Admin].', 'user/personal/missing_time', '2016-04-22 09:23:49', NULL, NULL, 'unread'),
(16, 1, 6, 'Your Extra Hours request has been deleted by Shoaib Mohmad [Admin].', 'user/personal/late_sitting', '2016-04-22 09:31:15', NULL, NULL, 'unread'),
(17, 6, 1, 'Loan has been requested by Shoaib Mohmad [Reporting Officer].', 'employees/loan_requests', '2016-05-19 10:11:52', 1, '2016-05-19 19:11:52', 'read'),
(18, 6, 13, 'Loan has been requested by Shoaib Mohmad [Reporting Officer].', 'employees/loan_requests', '2016-04-22 11:01:58', NULL, NULL, 'unread'),
(19, 6, 15, 'Loan has been requested by Shoaib Mohmad [Reporting Officer].', 'employees/loan_requests', '2016-04-22 11:01:58', NULL, NULL, 'unread'),
(20, 1, 1, 'Your Leave request has been approved by Shoaib Mohmad [Admin].', 'user/personal/leaves', '2016-04-22 11:37:19', NULL, NULL, 'unread'),
(21, 1, 1, 'Your Leave request has been approved by Shoaib Mohmad [Admin].', 'user/personal/leaves', '2016-04-22 11:37:41', NULL, NULL, 'unread'),
(22, 1, 0, 'Your Loan request has been deleted by Shoaib Mohmad [Admin].', 'user/personal/loan_requests', '2016-04-23 09:22:24', NULL, NULL, 'unread'),
(23, 1, 6, 'Your Leave request has been reject by Shoaib Mohmad [Admin].', 'user/personal/leaves', '2016-04-25 10:30:18', NULL, NULL, 'unread'),
(24, 1, 6, 'Your Leave request has been reject by Shoaib Mohmad [Admin].', 'user/personal/leaves', '2016-04-25 10:30:35', NULL, NULL, 'unread'),
(25, 1, 6, 'Your Leave request has been reject by Shoaib Mohmad [Admin].', 'user/personal/leaves', '2016-04-26 06:52:47', NULL, NULL, 'unread'),
(26, 1, 6, 'Your Leave request has been reject by Shoaib Mohmad [Admin].', 'user/personal/leaves', '2016-04-26 06:52:59', NULL, NULL, 'unread'),
(27, 1, 6, 'Your Leave request has been reject by Shoaib Mohmad [Admin].', 'user/personal/leaves', '2016-04-26 06:53:23', NULL, NULL, 'unread'),
(28, 1, 1, 'Your Missing Time request has been approved by Shoaib Mohmad [Admin].', 'user/personal/missing_time', '2016-05-04 11:21:46', NULL, NULL, 'unread'),
(29, 1, 1, 'Your Missing Time request has been deleted by Shoaib Mohmad [Admin].', 'user/personal/missing_time', '2016-05-19 10:29:43', 1, '2016-05-19 19:29:43', 'read'),
(30, 1, 1, 'Your Missing Time request has been deleted by Shoaib Mohmad [Admin].', 'user/personal/missing_time', '2016-05-09 04:31:26', NULL, NULL, 'unread'),
(31, 1, 1, 'Your Missing Time request has been approved by Shoaib Mohmad [Admin].', 'user/personal/missing_time', '2016-05-09 04:33:38', NULL, NULL, 'unread'),
(32, 13, 1, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:08:41', NULL, NULL, 'unread'),
(33, 13, 13, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:08:41', NULL, NULL, 'unread'),
(34, 13, 15, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:08:41', NULL, NULL, 'unread'),
(35, 1, 13, 'Your Leave request has been reject by Shoaib Mohmad [Admin].', 'user/personal/leaves', '2016-05-19 08:10:39', NULL, NULL, 'unread'),
(36, 1, 13, 'Your Leave request has been reject by Shoaib Mohmad [Admin].', 'user/personal/leaves', '2016-05-19 08:11:01', NULL, NULL, 'unread'),
(37, 13, 1, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:11:51', NULL, NULL, 'unread'),
(38, 13, 13, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:11:51', NULL, NULL, 'unread'),
(39, 13, 15, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:11:51', NULL, NULL, 'unread'),
(40, 1, 13, 'Your Leave request has been approved by Shoaib Mohmad [Admin].', 'user/personal/leaves', '2016-05-19 08:12:41', NULL, NULL, 'unread'),
(41, 1, 13, 'Your Leave request has been reject by Shoaib Mohmad [Admin].', 'user/personal/leaves', '2016-05-19 08:12:58', NULL, NULL, 'unread'),
(42, 13, 1, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:13:24', NULL, NULL, 'unread'),
(43, 13, 13, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:13:24', NULL, NULL, 'unread'),
(44, 13, 15, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:13:24', NULL, NULL, 'unread'),
(45, 13, 1, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:15:14', NULL, NULL, 'unread'),
(46, 13, 13, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:15:14', NULL, NULL, 'unread'),
(47, 13, 15, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:15:14', NULL, NULL, 'unread'),
(48, 13, 1, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:16:59', NULL, NULL, 'unread'),
(49, 13, 13, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:16:59', NULL, NULL, 'unread'),
(50, 13, 15, 'Leave has been requested by Ameera Ullah [Project Manager].', 'employees/leaves/employee_leaves', '2016-05-19 08:16:59', NULL, NULL, 'unread'),
(51, 13, 1, 'Loan has been requested by Ameera Ullah [Project Manager].', 'employees/loan_requests', '2016-05-22 18:07:00', 1, '2016-05-23 03:07:00', 'read'),
(52, 13, 13, 'Loan has been requested by Ameera Ullah [Project Manager].', 'employees/loan_requests', '2016-05-19 08:25:51', NULL, NULL, 'unread'),
(53, 13, 15, 'Loan has been requested by Ameera Ullah [Project Manager].', 'employees/loan_requests', '2016-05-19 08:25:51', NULL, NULL, 'unread'),
(54, 1, 12, 'Your Loan request has been rejected by Shoaib Mohmad [Admin].', 'user/personal/loan_requests', '2016-05-22 18:07:15', NULL, NULL, 'unread'),
(55, 1, 6, 'Your Leave request has been approved by Shoaib Mohmad [Admin].', 'user/personal/leaves', '2016-05-26 11:16:40', NULL, NULL, 'unread'),
(56, 1, 0, 'Your Loan request has been deleted by Shoaib Mohmad [Admin].', 'user/personal/loan_requests', '2016-05-26 11:44:51', NULL, NULL, 'unread');
-- --------------------------------------------------------
--
-- Table structure for table `office_settings`
--
CREATE TABLE `office_settings` (
`id` int(11) NOT NULL,
`weekends` varchar(64) NOT NULL,
`timing_from` time NOT NULL,
`timing_to` time NOT NULL,
`applicable_from` date NOT NULL,
`applicable_to` date DEFAULT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','changed','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `office_settings`
--
INSERT INTO `office_settings` (`id`, `weekends`, `timing_from`, `timing_to`, `applicable_from`, `applicable_to`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(2, '6,7', '09:00:00', '18:00:00', '2016-03-01', '2016-03-31', 1, '2016-05-16 06:49:33', 1, '2016-05-16 05:43:58', 'changed'),
(9, '6,7', '09:00:00', '18:00:00', '2016-05-01', NULL, 1, '2016-05-16 07:13:58', NULL, NULL, 'active'),
(10, '6,7', '09:15:00', '18:00:00', '2016-04-01', '2016-04-30', 1, '2016-05-16 07:17:04', 1, '2016-05-16 07:18:24', 'changed'),
(11, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-16 08:48:24', 1, '2016-05-19 14:53:42', 'changed'),
(12, '5,6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 05:53:42', 1, '2016-05-19 14:54:13', 'changed'),
(13, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 05:54:14', 1, '2016-05-19 14:54:57', 'changed'),
(14, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 05:54:57', 1, '2016-05-19 15:10:53', 'changed'),
(15, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:10:53', 1, '2016-05-19 15:15:25', 'changed'),
(16, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:15:25', 1, '2016-05-19 15:15:55', 'changed'),
(17, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:15:55', 1, '2016-05-19 15:16:20', 'changed'),
(18, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:16:20', 1, '2016-05-19 15:16:44', 'changed'),
(19, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:16:44', 1, '2016-05-19 15:17:24', 'changed'),
(20, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:17:24', 1, '2016-05-19 15:17:31', 'changed'),
(21, '6,7', '00:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:17:31', 1, '2016-05-19 15:17:49', 'changed'),
(22, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:17:49', 1, '2016-05-19 15:18:08', 'changed'),
(23, '6,7', '00:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:18:08', 1, '2016-05-19 15:18:26', 'changed'),
(24, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:18:26', 1, '2016-05-19 15:18:33', 'changed'),
(25, '6,7', '00:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:18:33', 1, '2016-05-19 15:19:03', 'changed'),
(26, '6,7', '09:20:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:19:03', 1, '2016-05-19 15:19:54', 'changed'),
(27, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:19:54', 1, '2016-05-19 15:20:00', 'changed'),
(28, '6,7', '09:00:00', '00:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:20:00', 1, '2016-05-19 15:21:19', 'changed'),
(29, '6,7', '09:00:00', '18:00:00', '2016-05-01', '1969-12-31', 1, '2016-05-19 06:21:19', 1, '2016-05-19 15:21:28', 'changed'),
(30, '6,7', '09:00:00', '18:00:00', '1970-01-01', '2016-04-30', 1, '2016-05-19 06:21:28', 1, '2016-05-19 15:23:24', 'changed'),
(31, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:23:24', 1, '2016-05-19 15:23:47', 'changed'),
(32, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:23:48', 1, '2016-05-19 15:24:34', 'changed'),
(33, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-05-31', 1, '2016-05-19 06:24:34', 1, '2016-05-19 15:24:41', 'changed'),
(34, '6,7', '09:00:00', '18:00:00', '2016-06-01', '2016-04-30', 1, '2016-05-19 06:24:41', 1, '2016-05-19 15:24:48', 'changed'),
(35, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:24:48', 1, '2016-05-19 15:24:56', 'changed'),
(36, '6,7', '09:00:00', '18:00:00', '2016-05-01', '1969-12-31', 1, '2016-05-19 06:24:56', 1, '2016-05-19 15:25:34', 'changed'),
(37, '6,7', '09:00:00', '18:00:00', '1970-01-01', '1969-12-31', 1, '2016-05-19 06:25:34', 1, '2016-05-19 15:25:37', 'changed'),
(38, '6,7', '09:00:00', '18:00:00', '1970-01-01', '2016-04-30', 1, '2016-05-19 06:25:37', 1, '2016-05-19 15:25:43', 'changed'),
(39, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:25:43', 1, '2016-05-19 15:38:58', 'changed'),
(40, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 06:38:58', 1, '2016-05-19 18:34:15', 'changed'),
(41, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-19 09:34:15', 1, '2016-05-26 21:56:14', 'changed'),
(42, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-26 11:26:14', 1, '2016-05-26 22:17:32', 'changed'),
(43, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-26 11:47:32', 1, '2016-05-28 14:30:40', 'changed'),
(44, '6,7', '09:00:00', '18:00:00', '2016-05-01', '2016-04-30', 1, '2016-05-28 04:00:40', 1, '2016-05-28 14:31:08', 'changed'),
(45, '6,7', '09:00:00', '18:00:00', '2016-05-01', NULL, 1, '2016-05-28 04:01:08', NULL, NULL, 'active');
-- --------------------------------------------------------
--
-- Table structure for table `off_day`
--
CREATE TABLE `off_day` (
`id` int(11) NOT NULL,
`employee_id` int(11) NOT NULL,
`date` date NOT NULL,
`created_by` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`approved_by` int(11) DEFAULT NULL,
`rejected_by` int(11) DEFAULT NULL,
`status` enum('active','approved','rejected','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `off_day`
--
INSERT INTO `off_day` (`id`, `employee_id`, `date`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `approved_by`, `rejected_by`, `status`) VALUES
(1, 1, '2016-03-30', 1, '2016-03-26 10:37:21', 1, '2016-04-22 18:16:34', 0, 1, 'deleted'),
(2, 1, '2016-03-25', 1, '2016-03-26 10:49:26', 1, '2016-03-26 10:55:25', 1, NULL, 'approved'),
(3, 1, '2016-03-31', 1, '2016-03-26 10:55:43', NULL, NULL, NULL, NULL, 'active'),
(4, 6, '2016-03-22', 6, '2016-03-26 11:12:46', 1, '2016-03-28 07:11:16', NULL, 1, 'rejected'),
(5, 12, '2016-03-29', 12, '2016-03-26 12:13:42', NULL, NULL, NULL, NULL, 'active'),
(6, 6, '2016-03-28', 6, '2016-03-28 10:57:13', 1, '2016-04-15 16:24:06', 1, NULL, 'approved');
-- --------------------------------------------------------
--
-- Table structure for table `questionnaire`
--
CREATE TABLE `questionnaire` (
`id` int(11) NOT NULL,
`question` text NOT NULL,
`created_by` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `questionnaire`
--
INSERT INTO `questionnaire` (`id`, `question`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 'How do you rate your performance? \r\n \r\n', 6, '2016-03-18 06:19:53', 1, '2016-03-18 11:52:21', 'active'),
(2, 'You attitude towards work? \r\n \r\n', 6, '2016-03-18 06:20:59', NULL, NULL, 'active'),
(3, 'Not been able to do? \r\n \r\n', 6, '2016-03-18 06:21:37', NULL, NULL, 'active'),
(4, 'Multi tasking \r\n \r\n', 6, '2016-03-18 06:22:06', NULL, NULL, 'active'),
(5, 'Taking Ownership \r\n \r\n', 6, '2016-03-18 06:22:33', NULL, NULL, 'active'),
(6, 'Needed to be reminded \r\n \r\n', 6, '2016-03-18 06:22:54', NULL, NULL, 'active'),
(7, 'Time management \r\n \r\n', 6, '2016-03-18 06:23:19', NULL, NULL, 'active'),
(8, 'Job timely delivery \r\n \r\n', 6, '2016-03-18 06:23:38', NULL, NULL, 'active'),
(9, 'Communication \r\n \r\n', 6, '2016-03-18 06:23:56', NULL, NULL, 'active'),
(10, 'Skills \r\n', 6, '2016-03-18 06:24:33', NULL, NULL, 'active'),
(11, 'Speed \r\n', 6, '2016-03-18 06:24:56', NULL, NULL, 'active'),
(12, 'New skills \r\n \r\n', 6, '2016-03-18 06:25:11', NULL, NULL, 'active'),
(13, 'Training Requirement \r\n \r\n', 6, '2016-03-18 06:25:30', NULL, NULL, 'active'),
(14, 'Initiative to Learn \r\n \r\n', 6, '2016-03-18 06:25:46', NULL, NULL, 'active'),
(15, 'Any Compliments from manager/Colleague? \r\n \r\n', 6, '2016-03-18 06:26:12', NULL, NULL, 'active'),
(16, 'Good candidate for future of co \r\n \r\n', 6, '2016-03-18 06:26:58', NULL, NULL, 'active'),
(17, 'Any thing we missed to appreciate you for? \r\n \r\n', 6, '2016-03-18 06:27:26', NULL, NULL, 'active'),
(18, 'Any value addition to company? \r\n \r\n', 6, '2016-03-18 06:28:00', NULL, NULL, 'active'),
(19, 'Where do you want to to see yourself in next 12 months? \r\n \r\n', 6, '2016-03-18 06:28:37', NULL, NULL, 'active'),
(20, 'How do you plan to do it? \r\n \r\n', 6, '2016-03-18 06:28:59', NULL, NULL, 'active'),
(21, 'How fair is company to you? \r\n \r\n', 6, '2016-03-18 06:29:20', 1, '2016-04-22 21:26:58', 'active'),
(22, 'What is one thing you want to change in company (except boss)? \r\n \r\n', 6, '2016-03-18 06:29:46', NULL, NULL, 'active'),
(23, 'Attendance \r\n \r\n', 6, '2016-03-18 06:30:08', NULL, NULL, 'active'),
(24, 'Rank yourself from 1 to 10?', 1, '2016-04-22 21:15:38', 1, '2016-04-22 21:18:02', 'deleted');
-- --------------------------------------------------------
--
-- Table structure for table `questionnaire_settings`
--
CREATE TABLE `questionnaire_settings` (
`id` int(10) UNSIGNED NOT NULL,
`questionnaire_attribute` varchar(64) NOT NULL,
`attribute_value` varchar(64) DEFAULT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `questionnaire_settings`
--
INSERT INTO `questionnaire_settings` (`id`, `questionnaire_attribute`, `attribute_value`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(7, 'evaluation_months', '1,4', 1, '2016-04-07 12:19:01', 1, '2016-04-23 14:02:05', 'active'),
(8, 'evaluation_authority', '2', 1, '2016-04-08 06:24:42', 1, '2016-04-23 14:02:05', 'active');
-- --------------------------------------------------------
--
-- Table structure for table `sent_sms`
--
CREATE TABLE `sent_sms` (
`id` int(11) UNSIGNED NOT NULL,
`recipients` varchar(512) NOT NULL,
`message` varchar(1024) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `sent_sms`
--
INSERT INTO `sent_sms` (`id`, `recipients`, `message`, `created_by`, `created_at`, `status`) VALUES
(1, '13', 'asd', 1, '2016-04-19 11:41:49', 'active');
-- --------------------------------------------------------
--
-- Table structure for table `sms_drafts`
--
CREATE TABLE `sms_drafts` (
`id` int(10) UNSIGNED NOT NULL DEFAULT '0',
`message` varchar(1024) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `sms_drafts`
--
INSERT INTO `sms_drafts` (`id`, `message`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(0, 'THIS IS A test DRAFT MESSAGE FROM imc', 1, '2016-04-25 10:25:12', 1, '2016-04-25 19:27:03', 'deleted');
-- --------------------------------------------------------
--
-- Table structure for table `trainings_attended`
--
CREATE TABLE `trainings_attended` (
`id` int(11) UNSIGNED NOT NULL,
`training_title` varchar(128) NOT NULL,
`training_description` text NOT NULL,
`training_country` varchar(32) NOT NULL,
`training_state` varchar(32) NOT NULL,
`training_city` varchar(64) NOT NULL,
`training_start` date NOT NULL,
`training_end` date NOT NULL,
`attended_by` varchar(128) NOT NULL,
`recommended_requested_by` int(11) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `trainings_attended`
--
INSERT INTO `trainings_attended` (`id`, `training_title`, `training_description`, `training_country`, `training_state`, `training_city`, `training_start`, `training_end`, `attended_by`, `recommended_requested_by`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(1, 'Oracle', 'Stored Procedures and Cursors', 'India', 'Jammu and Kashmir', 'Srinagar', '2016-03-17', '2016-03-18', '6', 1, 12, '2016-03-16 07:41:44', 1, '2016-03-16 11:18:02', 'active'),
(2, 'Codeigniter', 'Database Manipulation', 'Russia', '', '', '2016-03-23', '2016-03-18', '6', 6, 1, '2016-03-16 11:27:04', NULL, NULL, 'active'),
(3, 'sdgdxh', 'dhdhzjtzdhzh', 'Egypt', '', '', '2016-03-24', '2016-03-25', '12', 1, 1, '2016-03-16 11:33:42', NULL, NULL, 'active'),
(4, 'Web Designing', 'Html, CSS, Javascript', 'Azerbaijan', '<NAME>', 'Nishat', '2016-03-01', '2016-03-03', '6,12', 1, 6, '2016-03-17 14:46:57', NULL, NULL, 'active'),
(5, 'Web Designing', 'Html, CSS, Javascript', 'Dominican Republic', 'Maria Trinidad Sanchez', 'Nishat', '2016-03-10', '2016-03-15', '12', 12, 1, '2016-03-17 14:51:27', NULL, NULL, 'active');
-- --------------------------------------------------------
--
-- Table structure for table `trainings_recommended`
--
CREATE TABLE `trainings_recommended` (
`id` int(10) UNSIGNED NOT NULL,
`training_title` varchar(128) NOT NULL,
`training_description` text NOT NULL,
`training_country` varchar(32) NOT NULL,
`training_state` varchar(32) NOT NULL,
`training_city` varchar(64) NOT NULL,
`training_start` date NOT NULL,
`training_end` date NOT NULL,
`recommended_by` int(11) NOT NULL,
`recommended_for` varchar(128) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','approved','rejected','attended','deleted') NOT NULL DEFAULT 'active',
`approved_by` int(11) DEFAULT NULL,
`rejected_by` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `trainings_recommended`
--
INSERT INTO `trainings_recommended` (`id`, `training_title`, `training_description`, `training_country`, `training_state`, `training_city`, `training_start`, `training_end`, `recommended_by`, `recommended_for`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`, `approved_by`, `rejected_by`) VALUES
(1, 'Web Designing', 'Html, CSS, Javascript', 'Azerbaijan', 'B<NAME>', 'Nishat', '2016-03-01', '2016-03-03', 1, '12,6', 6, '2016-03-16 08:00:38', 1, '2016-04-23 15:17:09', 'approved', 1, 1),
(2, 'SERVER HOSTING', 'HANDLING OF SERVERS.', 'India', 'Jammu and Kashmir', 'JANDK', '2016-03-27', '2016-04-22', 0, '15', 1, '2016-04-23 05:49:17', NULL, NULL, 'active', NULL, NULL),
(3, 'SERVER HOSTING', 'SSSSSS', 'Belgium', 'Brabant Wallon', 'FFF', '2016-04-17', '2016-04-21', 0, '15', 1, '2016-04-23 05:51:57', NULL, NULL, 'active', NULL, NULL),
(4, 'SERVER HOSTING', 'SSSS', 'Afghanistan', 'Baghlan', 'SSSS', '2016-04-27', '2016-05-06', 0, '15', 1, '2016-04-23 05:55:48', NULL, NULL, 'active', NULL, NULL),
(5, 'dsfxgfhcgj', 'xhfgcjhv', 'Afghanistan', 'Badghis', 'gfcjhm,', '2016-01-01', '2016-05-01', 0, '15', 1, '2016-04-25 11:10:27', NULL, NULL, 'active', NULL, NULL),
(6, 'hgvjhkb,', 'cujvkjb', 'Afghanistan', 'Badakhshan', 'dfuyikln', '2015-12-04', '2016-04-30', 0, '13', 1, '2016-04-25 11:17:43', NULL, NULL, 'active', NULL, NULL),
(7, 'fdxhn', 'fdxhnj', 'Afghanistan', 'Baghlan', 'rdtfikug', '2016-04-01', '2016-04-25', 0, '13', 1, '2016-04-25 11:29:54', NULL, NULL, 'active', NULL, NULL),
(8, 'fxhgvj', 'dyuyk', 'Afghanistan', 'Balkh', 'dxhgjvk', '2016-04-01', '2016-04-25', 0, '12', 13, '2016-04-25 11:41:06', NULL, NULL, 'active', NULL, NULL),
(9, 'fchgjhv', 'rdyutjkv', 'Afghanistan', 'Badghis', 'esyjfv', '2016-04-03', '2016-04-09', 0, '13', 1, '2016-04-25 11:59:57', NULL, NULL, 'active', NULL, NULL),
(10, 'gfcmn', 'rdujyhvk', 'Algeria', 'Alger', 'dgchjhv', '2016-04-01', '2016-04-25', 12, '15,12', 1, '2016-04-25 12:05:47', 1, '2016-04-26 14:17:40', 'deleted', NULL, NULL),
(11, 'CCNA', 'Networking', 'Algeria', 'Alger', 'hgjhjbkj', '2015-04-01', '2015-10-31', 13, '15,6', 1, '2016-04-26 05:02:40', 1, '2016-04-26 14:17:24', 'approved', 1, NULL),
(12, 'teSt tRaIN', 'tesT TEST TEst', 'Bahamas', 'Bimini', 'TEST', '2016-04-05', '2016-04-19', 15, '16', 1, '2016-04-26 07:29:34', 1, '2016-05-26 21:50:01', 'approved', 1, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `trainings_requests`
--
CREATE TABLE `trainings_requests` (
`id` int(10) UNSIGNED NOT NULL,
`training_title` varchar(128) NOT NULL,
`training_description` text NOT NULL,
`training_location` varchar(128) NOT NULL,
`training_country` varchar(32) NOT NULL,
`training_state` varchar(32) NOT NULL,
`training_city` varchar(64) NOT NULL,
`training_start` date NOT NULL,
`training_end` date NOT NULL,
`requested_by` int(11) NOT NULL,
`requested_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','approved','rejected','attended','deleted') NOT NULL DEFAULT 'active',
`approved_by` int(11) DEFAULT NULL,
`rejected_by` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `trainings_requests`
--
INSERT INTO `trainings_requests` (`id`, `training_title`, `training_description`, `training_location`, `training_country`, `training_state`, `training_city`, `training_start`, `training_end`, `requested_by`, `requested_at`, `last_updated_by`, `last_updated_at`, `status`, `approved_by`, `rejected_by`) VALUES
(1, 'Web Designing', 'Html, CSS, Javascript', 'Dubai', 'Czeck Republic', 'Kralovehradecky', 'Nishat', '2016-03-10', '2016-03-15', 12, '2016-03-16 08:11:58', 1, '2016-04-15 16:31:57', 'approved', 1, 1);
-- --------------------------------------------------------
--
-- Table structure for table `travel_plans`
--
CREATE TABLE `travel_plans` (
`id` int(10) UNSIGNED NOT NULL,
`employees` varchar(128) NOT NULL,
`project_manager` int(11) NOT NULL,
`alternate_support` int(11) DEFAULT NULL,
`travel_purpose` text NOT NULL,
`travel_summary` text NOT NULL,
`travel_from_country` varchar(32) NOT NULL,
`travel_from_state` varchar(32) NOT NULL,
`travel_from_city` varchar(64) NOT NULL,
`travel_to_country` varchar(32) NOT NULL,
`travel_to_state` varchar(32) NOT NULL,
`travel_to_city` varchar(64) NOT NULL,
`travel_from_date` date NOT NULL,
`travel_to_date` date NOT NULL,
`travel_through` varchar(32) NOT NULL,
`travel_allowance` int(11) NOT NULL,
`food_allowance` int(11) NOT NULL,
`living_allowance` int(11) NOT NULL,
`success_rate` int(11) NOT NULL,
`created_by` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated_by` int(11) DEFAULT NULL,
`last_updated_at` timestamp NULL DEFAULT NULL,
`status` enum('active','deleted') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `travel_plans`
--
INSERT INTO `travel_plans` (`id`, `employees`, `project_manager`, `alternate_support`, `travel_purpose`, `travel_summary`, `travel_from_country`, `travel_from_state`, `travel_from_city`, `travel_to_country`, `travel_to_state`, `travel_to_city`, `travel_from_date`, `travel_to_date`, `travel_through`, `travel_allowance`, `food_allowance`, `living_allowance`, `success_rate`, `created_by`, `created_at`, `last_updated_by`, `last_updated_at`, `status`) VALUES
(2, '6,12', 13, 12, 'This is a Test Project Plan, no Purpose at all.', 'Nothing achieved.', 'India', 'Jammu and Kashmir', 'Srinagar', 'Afghanistan', 'Helmand', '<NAME>', '2016-03-25', '2016-03-31', 'Flight', 3000, 3000, 6000, 3, 1, '2016-03-18 06:18:07', 1, '2016-03-18 07:10:54', 'deleted'),
(3, '12,6', 13, 12, 'This is a Test Project Plan, no Purpose at all.', 'Nothing achieved. This is a Test Project Plan, no Purpose at all.', 'India', 'Jammu and Kashmir', 'Srinagar', 'Afghanistan', 'Helmand', '<NAME>', '2016-03-25', '2016-03-31', 'Flight', 3000, 3000, 6000, 5, 1, '2016-03-18 07:08:06', 1, '2016-05-26 21:47:28', 'active'),
(4, '14,6', 15, 13, ' cxn zx,', ' vcx,m .xdv/', 'American Samoa', 'Eastern', 'fdgshkj', 'Albania', 'Diber (Peshkopi)', 'rdstyku', '2016-03-01', '2016-03-31', 'Flight', 4000, 5000, 8000, 7, 1, '2016-04-26 05:59:16', 1, '2016-04-26 16:04:04', 'active'),
(5, '15,12', 15, 12, 'fAmiLY triP', 'tEsT', 'American Samoa', 'Manu''a', '456546', 'Afghanistan', 'Badakhshan', 'HTHty', '2016-04-19', '2016-04-29', 'Flight', 4654654, 546456, 5464, 3, 1, '2016-04-26 06:57:21', 1, '2016-04-26 15:57:34', 'deleted');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `advance_pay_requests`
--
ALTER TABLE `advance_pay_requests`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `company_details`
--
ALTER TABLE `company_details`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `company_holidays`
--
ALTER TABLE `company_holidays`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `company_letters`
--
ALTER TABLE `company_letters`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `company_products`
--
ALTER TABLE `company_products`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `customized_signatures`
--
ALTER TABLE `customized_signatures`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `employees`
--
ALTER TABLE `employees`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `employee_assets`
--
ALTER TABLE `employee_assets`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `employee_designations`
--
ALTER TABLE `employee_designations`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `employee_evaluation`
--
ALTER TABLE `employee_evaluation`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `employee_experience`
--
ALTER TABLE `employee_experience`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `employee_files`
--
ALTER TABLE `employee_files`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `employee_leaves`
--
ALTER TABLE `employee_leaves`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `employee_login`
--
ALTER TABLE `employee_login`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `employee_performance_reports`
--
ALTER TABLE `employee_performance_reports`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `employee_qualification`
--
ALTER TABLE `employee_qualification`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `employee_salary`
--
ALTER TABLE `employee_salary`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `employee_teams`
--
ALTER TABLE `employee_teams`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `late_sitting`
--
ALTER TABLE `late_sitting`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `leaves`
--
ALTER TABLE `leaves`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `letter_categories`
--
ALTER TABLE `letter_categories`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `loan_requests`
--
ALTER TABLE `loan_requests`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `miss_attendance`
--
ALTER TABLE `miss_attendance`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `notifications`
--
ALTER TABLE `notifications`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `office_settings`
--
ALTER TABLE `office_settings`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `off_day`
--
ALTER TABLE `off_day`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `questionnaire`
--
ALTER TABLE `questionnaire`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `questionnaire_settings`
--
ALTER TABLE `questionnaire_settings`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `sent_sms`
--
ALTER TABLE `sent_sms`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `sms_drafts`
--
ALTER TABLE `sms_drafts`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `trainings_attended`
--
ALTER TABLE `trainings_attended`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `trainings_recommended`
--
ALTER TABLE `trainings_recommended`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `trainings_requests`
--
ALTER TABLE `trainings_requests`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `travel_plans`
--
ALTER TABLE `travel_plans`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `advance_pay_requests`
--
ALTER TABLE `advance_pay_requests`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `company_details`
--
ALTER TABLE `company_details`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `company_holidays`
--
ALTER TABLE `company_holidays`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `company_letters`
--
ALTER TABLE `company_letters`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `company_products`
--
ALTER TABLE `company_products`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `customized_signatures`
--
ALTER TABLE `customized_signatures`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `employees`
--
ALTER TABLE `employees`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
--
-- AUTO_INCREMENT for table `employee_assets`
--
ALTER TABLE `employee_assets`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `employee_designations`
--
ALTER TABLE `employee_designations`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `employee_evaluation`
--
ALTER TABLE `employee_evaluation`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=70;
--
-- AUTO_INCREMENT for table `employee_experience`
--
ALTER TABLE `employee_experience`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=54;
--
-- AUTO_INCREMENT for table `employee_files`
--
ALTER TABLE `employee_files`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `employee_leaves`
--
ALTER TABLE `employee_leaves`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
--
-- AUTO_INCREMENT for table `employee_login`
--
ALTER TABLE `employee_login`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=82;
--
-- AUTO_INCREMENT for table `employee_performance_reports`
--
ALTER TABLE `employee_performance_reports`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22;
--
-- AUTO_INCREMENT for table `employee_qualification`
--
ALTER TABLE `employee_qualification`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36;
--
-- AUTO_INCREMENT for table `employee_salary`
--
ALTER TABLE `employee_salary`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT for table `employee_teams`
--
ALTER TABLE `employee_teams`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `late_sitting`
--
ALTER TABLE `late_sitting`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `leaves`
--
ALTER TABLE `leaves`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `letter_categories`
--
ALTER TABLE `letter_categories`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `loan_requests`
--
ALTER TABLE `loan_requests`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `miss_attendance`
--
ALTER TABLE `miss_attendance`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `notifications`
--
ALTER TABLE `notifications`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=57;
--
-- AUTO_INCREMENT for table `office_settings`
--
ALTER TABLE `office_settings`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=46;
--
-- AUTO_INCREMENT for table `off_day`
--
ALTER TABLE `off_day`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `questionnaire`
--
ALTER TABLE `questionnaire`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;
--
-- AUTO_INCREMENT for table `questionnaire_settings`
--
ALTER TABLE `questionnaire_settings`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `sent_sms`
--
ALTER TABLE `sent_sms`
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `trainings_attended`
--
ALTER TABLE `trainings_attended`
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `trainings_recommended`
--
ALTER TABLE `trainings_recommended`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
--
-- AUTO_INCREMENT for table `trainings_requests`
--
ALTER TABLE `trainings_requests`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `travel_plans`
--
ALTER TABLE `travel_plans`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
DROP DATABASE IF EXISTS corporation_db;
CREATE DATABASE corporation_db;
USE corporation_db;
CREATE TABLE department (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(30) NOT NULL,
);
CREATE TABLE roles (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
department_id INT,
title VARCHAR(30) NOT NULL,
salary DECIMAL,
FOREIGN KEY(department_id) REFERENCES department(id) ON DELETE SET NULL
);
CREATE TABLE employee (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
role_id INT,
first_name VARCHAR (30) NOT NULL,
last_name VARCHAR (30) NOT NULL,
manager_id INT,
FOREIGN KEY(role_id) REFERENCES roles(id) ON DELETE SET NULL,
);
|
DELETE FROM `dimvalues` WHERE `dimvalid` NOT IN
(SELECT `link_ds_dimvals`.`dimvalid` FROM `link_ds_dimvals`);
DELETE FROM `dimensions` WHERE `dimid` NOT IN
(SELECT `dimvalues`.`dimid` FROM `dimvalues`); |
CREATE DEFINER=`neon-user`@`localhost` PROCEDURE `prc_WSGenerateVendorSippySheet`(
IN `p_VendorID` INT ,
IN `p_Trunks` varchar(200),
IN `p_Effective` VARCHAR(50)
,
IN `p_CustomDate` DATE
)
BEGIN
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
call vwVendorSippySheet(p_VendorID,p_Trunks,p_Effective,p_CustomDate);
SELECT
`Action [A|D|U|S|SA`,
id ,
vendorRate.Prefix,
COUNTRY,
Preference ,
`Interval 1` ,
`Interval N` ,
`Price 1` ,
`Price N` ,
`1xx Timeout` ,
`2xx Timeout` ,
`Huntstop` ,
Forbidden ,
`Activation Date` ,
`Expiration Date`
FROM tmp_VendorSippySheet_ vendorRate
WHERE vendorRate.AccountId = p_VendorID
And FIND_IN_SET(vendorRate.TrunkId,p_Trunks) != 0;
/*
SELECT
`Action [A|D|U|S|SA`,
id ,
Prefix,
COUNTRY,
Preference ,
`Interval 1` ,
`Interval N` ,
`Price 1` ,
`Price N` ,
`1xx Timeout` ,
`2xx Timeout` ,
`Huntstop` ,
Forbidden ,
`Activation Date` ,
`Expiration Date`
FROM
(
SELECT
`Action [A|D|U|S|SA`,
id ,
vendorRate.Prefix,
COUNTRY,
Preference ,
`Interval 1` ,
`Interval N` ,
`Price 1` ,
`Price N` ,
`1xx Timeout` ,
`2xx Timeout` ,
`Huntstop` ,
Forbidden ,
`Activation Date` ,
`Expiration Date`
FROM tmp_VendorSippySheet_ vendorRate
UNION ALL
SELECT
`Action [A|D|U|S|SA`,
id ,
vendorRate.Prefix,
COUNTRY,
Preference ,
`Interval 1` ,
`Interval N` ,
`Price 1` ,
`Price N` ,
`1xx Timeout` ,
`2xx Timeout` ,
`Huntstop` ,
Forbidden ,
`Activation Date` ,
`Expiration Date`
FROM tmp_VendorArhiveSippySheet_ vendorRate
) tmp;
-- WHERE vendorRate.AccountId = p_VendorID
-- And FIND_IN_SET(vendorRate.TrunkId,p_Trunks) != 0;
*/
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
END |
Insert into EG_ACTION (ID,NAME,URL,QUERYPARAMS,PARENTMODULE,ORDERNUMBER,DISPLAYNAME,ENABLED,CONTEXTROOT,VERSION,CREATEDBY,CREATEDDATE,LASTMODIFIEDBY,LASTMODIFIEDDATE,APPLICATION) values (NEXTVAL('SEQ_EG_ACTION'),'WorksPackageSave','/tender/worksPackage-save.action',null,(select id from EG_MODULE where name = 'WorksPackage'),0,'WorksPackageSave','false','egworks',0,1,now(),1,now(),(select id from eg_module where name = 'Works Management'));
Insert into eg_roleaction (roleid, actionid) values ((select id from eg_role where name = 'Super User'),(select id from eg_action where name ='WorksPackageSave' and contextroot = 'egworks'));
Insert into EG_ACTION (ID,NAME,URL,QUERYPARAMS,PARENTMODULE,ORDERNUMBER,DISPLAYNAME,ENABLED,CONTEXTROOT,VERSION,CREATEDBY,CREATEDDATE,LASTMODIFIEDBY,LASTMODIFIEDDATE,APPLICATION) values (NEXTVAL('SEQ_EG_ACTION'),'WorksTenderFileNoUniqueCheckAjax','/tender/ajaxWorksPackage-tenderFileNumberUniqueCheck.action',null,(select id from EG_MODULE where name = 'WorksPackage'),0,'WorksTenderFileNoUniqueCheckAjax','false','egworks',0,1,now(),1,now(),(select id from eg_module where name = 'Works Management'));
Insert into eg_roleaction (roleid, actionid) values ((select id from eg_role where name = 'Super User'),(select id from eg_action where name ='WorksTenderFileNoUniqueCheckAjax' and contextroot = 'egworks'));
Insert into EG_ACTION (ID,NAME,URL,QUERYPARAMS,PARENTMODULE,ORDERNUMBER,DISPLAYNAME,ENABLED,CONTEXTROOT,VERSION,CREATEDBY,CREATEDDATE,LASTMODIFIEDBY,LASTMODIFIEDDATE,APPLICATION) values (NEXTVAL('SEQ_EG_ACTION'),'WorksPackagePDF','/tender/worksPackage-viewWorksPackagePdf.action',null,(select id from EG_MODULE where name = 'WorksPackage'),0,'WorksPackagePDF','false','egworks',0,1,now(),1,now(),(select id from eg_module where name = 'Works Management'));
Insert into eg_roleaction (roleid, actionid) values ((select id from eg_role where name = 'Super User'),(select id from eg_action where name ='WorksPackagePDF' and contextroot = 'egworks'));
Insert into EG_ACTION (ID,NAME,URL,QUERYPARAMS,PARENTMODULE,ORDERNUMBER,DISPLAYNAME,ENABLED,CONTEXTROOT,VERSION,CREATEDBY,CREATEDDATE,LASTMODIFIEDBY,LASTMODIFIEDDATE,APPLICATION) values (NEXTVAL('SEQ_EG_ACTION'),'WorksPackageEdit','/tender/worksPackage-edit.action',null,(select id from EG_MODULE where name = 'WorksPackage'),0,'WorksPackageEdit','false','egworks',0,1,now(),1,now(),(select id from eg_module where name = 'Works Management'));
Insert into eg_roleaction (roleid, actionid) values ((select id from eg_role where name = 'Super User'),(select id from eg_action where name ='WorksPackageEdit' and contextroot = 'egworks'));
update eg_action set url='/tender/searchWorksPackage.action' where name='SearchWorksPackage' and contextroot = 'egworks';
Insert into EG_ACTION (ID,NAME,URL,QUERYPARAMS,PARENTMODULE,ORDERNUMBER,DISPLAYNAME,ENABLED,CONTEXTROOT,VERSION,CREATEDBY,CREATEDDATE,LASTMODIFIEDBY,LASTMODIFIEDDATE,APPLICATION) values (NEXTVAL('SEQ_EG_ACTION'),'WorksPackageSearch','/tender/searchWorksPackage-search.action',null,(select id from EG_MODULE where name = 'WorksPackage'),0,'WorksPackageSearch','false','egworks',0,1,now(),1,now(),(select id from eg_module where name = 'Works Management'));
Insert into eg_roleaction (roleid, actionid) values ((select id from eg_role where name = 'Super User'),(select id from eg_action where name ='WorksPackageSearch' and contextroot = 'egworks'));
Insert into EG_ACTION (ID,NAME,URL,QUERYPARAMS,PARENTMODULE,ORDERNUMBER,DISPLAYNAME,ENABLED,CONTEXTROOT,VERSION,CREATEDBY,CREATEDDATE,LASTMODIFIEDBY,LASTMODIFIEDDATE,APPLICATION) values (NEXTVAL('SEQ_EG_ACTION'),'AjaxSearchWorksPackageNumber','/tender/ajaxWorksPackage-searchWorksPackageNumber.action',null,(select id from EG_MODULE where name = 'WorksPackage'),0,'AjaxSearchWorksPackageNumber','false','egworks',0,1,now(),1,now(),(select id from eg_module where name = 'Works Management'));
Insert into eg_roleaction (roleid, actionid) values ((select id from eg_role where name = 'Super User'),(select id from eg_action where name ='AjaxSearchWorksPackageNumber' and contextroot = 'egworks'));
Insert into EG_ACTION (ID,NAME,URL,QUERYPARAMS,PARENTMODULE,ORDERNUMBER,DISPLAYNAME,ENABLED,CONTEXTROOT,VERSION,CREATEDBY,CREATEDDATE,LASTMODIFIEDBY,LASTMODIFIEDDATE,APPLICATION) values (NEXTVAL('SEQ_EG_ACTION'),'AjaxTRPresentForWPCheck','/tender/ajaxWorksPackage-isTRPresentForWPCheck.action',null,(select id from EG_MODULE where name = 'WorksPackage'),0,'AjaxTRPresentForWPCheck','false','egworks',0,1,now(),1,now(),(select id from eg_module where name = 'Works Management'));
Insert into eg_roleaction (roleid, actionid) values ((select id from eg_role where name = 'Super User'),(select id from eg_action where name ='AjaxTRPresentForWPCheck' and contextroot = 'egworks'));
Insert into EG_ACTION (ID,NAME,URL,QUERYPARAMS,PARENTMODULE,ORDERNUMBER,DISPLAYNAME,ENABLED,CONTEXTROOT,VERSION,CREATEDBY,CREATEDDATE,LASTMODIFIEDBY,LASTMODIFIEDDATE,APPLICATION) values (NEXTVAL('SEQ_EG_ACTION'),'AjaxWPSearchTenderFileNumber','/tender/ajaxWorksPackage-searchTenderFileNumber.action',null,(select id from EG_MODULE where name = 'WorksPackage'),0,'AjaxWPSearchTenderFileNumber','false','egworks',0,1,now(),1,now(),(select id from eg_module where name = 'Works Management'));
Insert into eg_roleaction (roleid, actionid) values ((select id from eg_role where name = 'Super User'),(select id from eg_action where name ='AjaxWPSearchTenderFileNumber' and contextroot = 'egworks'));
Insert into EG_ACTION (ID,NAME,URL,QUERYPARAMS,PARENTMODULE,ORDERNUMBER,DISPLAYNAME,ENABLED,CONTEXTROOT,VERSION,CREATEDBY,CREATEDDATE,LASTMODIFIEDBY,LASTMODIFIEDDATE,APPLICATION) values (NEXTVAL('SEQ_EG_ACTION'),'AjaxWPSearchEstimateNumber','/tender/ajaxWorksPackage-searchEstimateNumber.action',null,(select id from EG_MODULE where name = 'WorksPackage'),0,'AjaxWPSearchEstimateNumber','false','egworks',0,1,now(),1,now(),(select id from eg_module where name = 'Works Management'));
Insert into eg_roleaction (roleid, actionid) values ((select id from eg_role where name = 'Super User'),(select id from eg_action where name ='AjaxWPSearchEstimateNumber' and contextroot = 'egworks'));
--rollback delete from eg_roleaction where actionid in (select id from eg_action where name in ('WorksPackageSave', 'WorksTenderFileNoUniqueCheckAjax','WorksPackagePDF','WorksPackageEdit','WorksPackageSearch','AjaxSearchWorksPackageNumber','AjaxTRPresentForWPCheck','AjaxWPSearchTenderFileNumber','AjaxWPSearchEstimateNumber') and contextroot = 'egworks') and roleid in(select id from eg_role where name = 'Super User');
--rollback delete from eg_action where name in ('WorksPackageSave','WorksTenderFileNoUniqueCheckAjax','WorksPackagePDF','WorksPackageEdit','WorksPackageSearch','AjaxSearchWorksPackageNumber','AjaxTRPresentForWPCheck','AjaxWPSearchTenderFileNumber','AjaxWPSearchEstimateNumber') and contextroot = 'egworks'; |
<reponame>aaronpk/OwnYourSwarm<filename>db/0011.sql
ALTER TABLE users
ADD COLUMN `add_tags` varchar(255) DEFAULT '' AFTER `micropub_style`;
|
<reponame>jerelynlee/census
-- P12E. SEX BY AGE (NATIVE HAWAIIAN AND OTHER PACIFIC ISLANDER ALONE)
-- designed to work with the IRE Census bulk data exports
-- see http://census.ire.org/data/bulkdata.html
CREATE TABLE ire_p12e (
geoid VARCHAR(11) NOT NULL,
sumlev VARCHAR(3) NOT NULL,
state VARCHAR(2) NOT NULL,
county VARCHAR(3),
cbsa VARCHAR(5),
csa VARCHAR(3),
necta VARCHAR(5),
cnecta VARCHAR(3),
name VARCHAR(90) NOT NULL,
pop100 INTEGER NOT NULL,
hu100 INTEGER NOT NULL,
pop100_2000 INTEGER,
hu100_2000 INTEGER,
p012e001 INTEGER,
p012e001_2000 INTEGER,
p012e002 INTEGER,
p012e002_2000 INTEGER,
p012e003 INTEGER,
p012e003_2000 INTEGER,
p012e004 INTEGER,
p012e004_2000 INTEGER,
p012e005 INTEGER,
p012e005_2000 INTEGER,
p012e006 INTEGER,
p012e006_2000 INTEGER,
p012e007 INTEGER,
p012e007_2000 INTEGER,
p012e008 INTEGER,
p012e008_2000 INTEGER,
p012e009 INTEGER,
p012e009_2000 INTEGER,
p012e010 INTEGER,
p012e010_2000 INTEGER,
p012e011 INTEGER,
p012e011_2000 INTEGER,
p012e012 INTEGER,
p012e012_2000 INTEGER,
p012e013 INTEGER,
p012e013_2000 INTEGER,
p012e014 INTEGER,
p012e014_2000 INTEGER,
p012e015 INTEGER,
p012e015_2000 INTEGER,
p012e016 INTEGER,
p012e016_2000 INTEGER,
p012e017 INTEGER,
p012e017_2000 INTEGER,
p012e018 INTEGER,
p012e018_2000 INTEGER,
p012e019 INTEGER,
p012e019_2000 INTEGER,
p012e020 INTEGER,
p012e020_2000 INTEGER,
p012e021 INTEGER,
p012e021_2000 INTEGER,
p012e022 INTEGER,
p012e022_2000 INTEGER,
p012e023 INTEGER,
p012e023_2000 INTEGER,
p012e024 INTEGER,
p012e024_2000 INTEGER,
p012e025 INTEGER,
p012e025_2000 INTEGER,
p012e026 INTEGER,
p012e026_2000 INTEGER,
p012e027 INTEGER,
p012e027_2000 INTEGER,
p012e028 INTEGER,
p012e028_2000 INTEGER,
p012e029 INTEGER,
p012e029_2000 INTEGER,
p012e030 INTEGER,
p012e030_2000 INTEGER,
p012e031 INTEGER,
p012e031_2000 INTEGER,
p012e032 INTEGER,
p012e032_2000 INTEGER,
p012e033 INTEGER,
p012e033_2000 INTEGER,
p012e034 INTEGER,
p012e034_2000 INTEGER,
p012e035 INTEGER,
p012e035_2000 INTEGER,
p012e036 INTEGER,
p012e036_2000 INTEGER,
p012e037 INTEGER,
p012e037_2000 INTEGER,
p012e038 INTEGER,
p012e038_2000 INTEGER,
p012e039 INTEGER,
p012e039_2000 INTEGER,
p012e040 INTEGER,
p012e040_2000 INTEGER,
p012e041 INTEGER,
p012e041_2000 INTEGER,
p012e042 INTEGER,
p012e042_2000 INTEGER,
p012e043 INTEGER,
p012e043_2000 INTEGER,
p012e044 INTEGER,
p012e044_2000 INTEGER,
p012e045 INTEGER,
p012e045_2000 INTEGER,
p012e046 INTEGER,
p012e046_2000 INTEGER,
p012e047 INTEGER,
p012e047_2000 INTEGER,
p012e048 INTEGER,
p012e048_2000 INTEGER,
p012e049 INTEGER,
p012e049_2000 INTEGER,
PRIMARY KEY (geoid)
);
|
<gh_stars>1-10
.read lab12.sql
-- Q5
CREATE TABLE greatstudents AS
SELECT a.date, a.color, a.pet, a.number, b.number
FROM students AS a, fa17students AS b
WHERE a.date = b.date AND a.color = b.color AND a.pet = b.pet;
-- Q6
CREATE TABLE sevens AS
SELECT a.seven FROM students AS a, checkboxes AS b
WHERE a.time = b.time AND a.number = 7 AND b.'7' = 'True';
-- Q7
CREATE TABLE fa17favnum AS
SELECT number, COUNT(*) AS count FROM fa17students GROUP BY number ORDER BY count DESC LIMIT 1;
-- To pass the ok test you need to sort(order by) alphabetically pet ASC
CREATE TABLE fa17favpets AS
SELECT pet, COUNT(*) AS count FROM fa17students GROUP BY pet ORDER BY count DESC, pet ASC LIMIT 10;
CREATE TABLE sp18favpets AS
SELECT pet, COUNT(*) AS count FROM students GROUP BY pet ORDER BY count DESC, pet ASC LIMIT 10;
CREATE TABLE sp18dog AS
SELECT pet, COUNT(*) AS count FROM students WHERE pet = 'dog' GROUP BY pet;
CREATE TABLE sp18alldogs AS
SELECT pet, COUNT(*) AS count FROM students WHERE pet LIKE '%dog%';
CREATE TABLE obedienceimages AS
SELECT seven, denero, COUNT(*) FROM students WHERE seven = '7' GROUP BY denero;
-- Q8
CREATE TABLE smallest_int_count AS
SELECT smallest, COUNT(*) FROM students GROUP BY smallest ORDER BY smallest ASC
|
/*
----------------------------------------------------------------------------
Increase a Database File in Specified Increments
----------------------------------------------------------------------------
Author: <NAME> (t: @EitanBlumin | b: eitanblumin.com)
Creation Date: 2021-07-14
----------------------------------------------------------------------------
Description:
This script uses small intervals to grow a file (in the current database)
up to a specific size or percentage (of used space).
This can be useful when growing transaction log files
while minimizing VLF count.
Change the parameter values below to customize the behavior.
----------------------------------------------------------------------------
!!! DON'T FORGET TO SET THE CORRECT DATABASE NAME !!!
----------------------------------------------------------------------------
Change log:
2021-07-14 - First version
----------------------------------------------------------------------------
Parameters:
----------------------------------------------------------------------------
*/
DECLARE
@DatabaseName SYSNAME = NULL -- Leave NULL to use current database context
,@FileName SYSNAME = NULL -- Leave NULL to grow the file with the lowest % free space
,@FileType SYSNAME = 'LOG' -- If @FileName is NULL, use this to filter for a specific file type (ROWS | LOG | NULL).
,@TargetSizeMB INT = 1024 * 8 -- Leave NULL to rely on @MinPercentFree exclusively.
,@MinPercentFree INT = 50 -- Leave NULL to rely on @TargetSizeMB exclusively.
-- Either @TargetSizeMB or @MinPercentFree must be specified.
-- If both @TargetSizeMB and @MinPercentFree are provided, the largest of them will be used.
,@IntervalMB INT = 1024 -- Leave NULL to grow the file in a single interval
,@DelayBetweenGrowths VARCHAR(12) = '00:00:01' -- Delay to wait between growth iterations (in 'hh:mm[[:ss].mss]' format). Leave NULL to disable delay. For more info, see the 'time_to_execute' argument of WAITFOR DELAY: https://docs.microsoft.com/en-us/sql/t-sql/language-elements/waitfor-transact-sql?view=sql-server-ver15#arguments
,@WhatIf BIT = 1 -- Set to 1 to only print the commands but not run them.
----------------------------------------------------------------------------
-- DON'T CHANGE ANYTHING BELOW THIS LINE --
----------------------------------------------------------------------------
SET NOCOUNT, ARITHABORT, XACT_ABORT ON;
SET ANSI_WARNINGS OFF;
DECLARE @CurrSizeMB INT, @StartTime DATETIME, @sp_executesql NVARCHAR(1000);
DECLARE @CMD NVARCHAR(MAX), @SpaceUsedMB INT;
DECLARE @SpaceUsedPct VARCHAR(10), @TargetPct VARCHAR(10), @NewSizeMB INT;
SET @DatabaseName = ISNULL(@DatabaseName, DB_NAME());
IF @DatabaseName IS NULL
BEGIN
RAISERROR(N'Database "%s" was not found on this server.',16,1,@DatabaseName);
GOTO Quit;
END
IF DATABASEPROPERTYEX(@DatabaseName, 'Updateability') <> 'READ_WRITE'
BEGIN
RAISERROR(N'Database "%s" is not writeable.',16,1,@DatabaseName);
GOTO Quit;
END
IF @TargetSizeMB IS NULL AND @MinPercentFree IS NULL
BEGIN
RAISERROR(N'Either @TargetSizeMB or @MinPercentFree must be specified!', 16, 1);
GOTO Quit;
END
IF @IntervalMB < 1
BEGIN
RAISERROR(N'@IntervalMB must be an integer value of 1 or higher (or NULL if you want to grow using a single interval)', 16,1)
GOTO Quit;
END
SET @sp_executesql = QUOTENAME(@DatabaseName) + '..sp_executesql'
SET @CMD = N'
SELECT TOP 1
@FileName = [name]
,@CurrSizeMB = size / 128
,@SpaceUsedMB = CAST(FILEPROPERTY([name], ''SpaceUsed'') AS int) / 128.0
FROM sys.database_files
WHERE ([name] = @FileName OR @FileName IS NULL)
AND ([size] / 128 < @TargetSizeMB OR @TargetSizeMB IS NULL OR [name] = @FileName)
AND type IN (0,1) -- data and log files only'
+ CASE WHEN @FileType IS NOT NULL THEN N'
AND type_desc = @FileType'
ELSE N'' END
+ N'
ORDER BY CAST(FILEPROPERTY([name], ''SpaceUsed'') AS float) / size DESC;'
IF @WhatIf = 1 PRINT @CMD;
EXEC @sp_executesql @CMD, N'@FileType SYSNAME, @FileName SYSNAME OUTPUT, @CurrSizeMB INT OUTPUT, @SpaceUsedMB INT OUTPUT, @TargetSizeMB INT'
, @FileType, @FileName OUTPUT, @CurrSizeMB OUTPUT, @SpaceUsedMB OUTPUT, @TargetSizeMB
SET @TargetSizeMB = (
SELECT MAX(val)
FROM (VALUES
(@TargetSizeMB),(CEILING(@SpaceUsedMB / (CAST(@MinPercentFree as float) / 100.0)))
) AS v(val)
)
SET @SpaceUsedPct = CAST( CEILING(@SpaceUsedMB * 100.0 / @CurrSizeMB) as varchar(10)) + '%'
SET @TargetPct = CAST( CEILING(@SpaceUsedMB * 100.0 / @TargetSizeMB) as varchar(10)) + '%'
IF @SpaceUsedMB IS NOT NULL
RAISERROR(N'-- File "%s" current size: %d MB, used space: %d MB (%s), target size: %d MB (%s)',0,1,@FileName,@CurrSizeMB,@SpaceUsedMB,@SpaceUsedPct,@TargetSizeMB,@TargetPct) WITH NOWAIT;
IF @SpaceUsedMB IS NULL OR @CurrSizeMB >= @TargetSizeMB
BEGIN
PRINT N'-- Nothing to grow'
GOTO Quit;
END
WHILE @CurrSizeMB < @TargetSizeMB
BEGIN
SET @CurrSizeMB = @CurrSizeMB+@IntervalMB
IF @CurrSizeMB > @TargetSizeMB OR @IntervalMB IS NULL SET @CurrSizeMB = @TargetSizeMB
SET @CMD = N'ALTER DATABASE ' + QUOTENAME(@DatabaseName) + N' MODIFY FILE (NAME = N' + QUOTENAME(@FileName, N'''') + N' , SIZE = ' + CONVERT(nvarchar, @CurrSizeMB) + N'MB); -- ' + CONVERT(nvarchar(25),GETDATE(),121)
RAISERROR(N'%s',0,1,@CMD) WITH NOWAIT;
IF @WhatIf = 1
PRINT N'-- @WhatIf was set to 1. Skipping execution.'
ELSE
BEGIN
EXEC @sp_executesql @CMD
-- Re-check new file size
EXEC @sp_executesql N'SELECT @NewSizeInMB = [size]/128 FROM sys.database_files WHERE [name] = @FileName;'
, N'@FileName SYSNAME, @NewSizeInMB FLOAT OUTPUT', @FileName, @NewSizeMB OUTPUT
-- See if target size was successfully reached
IF @NewSizeMB < @CurrSizeMB
BEGIN
RAISERROR(N'-- Unable to grow beyond %d MB. Stopping operation.', 12, 1, @NewSizeMB) WITH NOWAIT;
BREAK;
END
-- Sleep between iterations
IF @DelayBetweenGrowths IS NOT NULL
WAITFOR DELAY @DelayBetweenGrowths;
END
END
PRINT N'-- Done - ' + CONVERT(nvarchar(25),GETDATE(),121)
Quit: |
<gh_stars>1000+
---- AD_ImpFormat for IFA Manufacturer ---
-- 2019-03-26T18:45:02.647
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat (AD_Client_ID,AD_ImpFormat_ID,AD_Org_ID,AD_Table_ID,Created,CreatedBy,FormatType,IsActive,IsManualImport,IsMultiLine,Name,Processing,Updated,UpdatedBy) VALUES (0,540032,0,541197,TO_TIMESTAMP('2019-03-26 18:45:02','YYYY-MM-DD HH24:MI:SS'),100,'S','Y','N','N','IFA Hersteller','N',TO_TIMESTAMP('2019-03-26 18:45:02','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:11.309
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564557,540032,541078,0,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00ssatz',1,1,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:11.382
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564558,540032,541079,0,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00adrnr',2,2,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:11.448
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564559,540032,541080,0,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100,'D','.','N','Y','b00gdat',3,3,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:11.515
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564560,540032,541081,0,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00lkz',4,4,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:11.592
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564561,540032,541082,0,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00sname',5,5,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:11.657
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564562,540032,541083,0,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00name1',6,6,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:11.719
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564563,540032,541084,0,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00name2',7,7,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:11.778
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564564,540032,541085,0,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00name3',8,8,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:11.837
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564565,540032,541086,0,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00land',9,9,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:11.897
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564566,540032,541087,0,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00plzzu1',10,10,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:11.965
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564567,540032,541088,0,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00ortzu',11,11,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.025
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564568,540032,541089,0,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00str',12,12,TO_TIMESTAMP('2019-03-26 18:45:11','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.093
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564569,540032,541090,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00hnrv',13,13,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.165
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564570,540032,541091,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00hnrvz',14,14,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.223
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564571,540032,541092,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00hnrb',15,15,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.284
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564572,540032,541093,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00hnrbz',16,16,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.343
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564573,540032,541094,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00plzpf1',17,17,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.402
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564574,540032,541095,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00ortpf',18,18,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.459
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564575,540032,541096,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00pf1',19,19,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.520
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564576,540032,541097,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00plzgk1',20,20,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.585
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564577,540032,541098,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00tel1',21,21,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.648
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564578,540032,541099,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00tel2',22,22,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.703
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564579,540032,541100,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00fax1',23,23,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.759
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564580,540032,541101,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00fax2',24,24,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.815
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564581,540032,541102,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00email',25,25,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.871
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564582,540032,541103,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00email2',26,26,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.933
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564583,540032,541104,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00homepag',27,27,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:12.997
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564586,540032,541105,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','b00regnr9',28,28,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:13.057
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564589,540032,541106,0,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100,'D','.','N','Y','Erstellt',29,29,TO_TIMESTAMP('2019-03-26 18:45:12','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:13.127
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564591,540032,541107,0,TO_TIMESTAMP('2019-03-26 18:45:13','YYYY-MM-DD HH24:MI:SS'),100,'S','.','N','Y','Import-Fehlermeldung',30,30,TO_TIMESTAMP('2019-03-26 18:45:13','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:13.182
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564593,540032,541108,0,TO_TIMESTAMP('2019-03-26 18:45:13','YYYY-MM-DD HH24:MI:SS'),100,'C','.','N','Y','Aktiv',31,31,TO_TIMESTAMP('2019-03-26 18:45:13','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:13.240
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564594,540032,541109,0,TO_TIMESTAMP('2019-03-26 18:45:13','YYYY-MM-DD HH24:MI:SS'),100,'C','.','N','Y','Verarbeitet',32,32,TO_TIMESTAMP('2019-03-26 18:45:13','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:13.296
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564595,540032,541110,0,TO_TIMESTAMP('2019-03-26 18:45:13','YYYY-MM-DD HH24:MI:SS'),100,'D','.','N','Y','Aktualisiert',33,33,TO_TIMESTAMP('2019-03-26 18:45:13','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:13.355
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_ImpFormat_Row (AD_Client_ID,AD_Column_ID,AD_ImpFormat_ID,AD_ImpFormat_Row_ID,AD_Org_ID,Created,CreatedBy,DataType,DecimalPoint,DivideBy100,IsActive,Name,SeqNo,StartNo,Updated,UpdatedBy) VALUES (0,564597,540032,541111,0,TO_TIMESTAMP('2019-03-26 18:45:13','YYYY-MM-DD HH24:MI:SS'),100,'C','.','N','Y','Import Pharma BPartners',34,34,TO_TIMESTAMP('2019-03-26 18:45:13','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 2019-03-26T18:45:59.278
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_ImpFormat_Row WHERE AD_ImpFormat_Row_ID=541106
;
-- 2019-03-26T18:45:59.302
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_ImpFormat_Row WHERE AD_ImpFormat_Row_ID=541107
;
-- 2019-03-26T18:45:59.380
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_ImpFormat_Row WHERE AD_ImpFormat_Row_ID=541108
;
-- 2019-03-26T18:45:59.413
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_ImpFormat_Row WHERE AD_ImpFormat_Row_ID=541109
;
-- 2019-03-26T18:45:59.440
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_ImpFormat_Row WHERE AD_ImpFormat_Row_ID=541110
;
-- 2019-03-26T18:45:59.577
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_ImpFormat_Row WHERE AD_ImpFormat_Row_ID=541111
;
INSERT INTO public.c_dataimport (ad_client_id, ad_impformat_id, ad_org_id, c_dataimport_id, created, createdby, isactive, updated, updatedby) VALUES (1000000, 540032, 1000000, 540002, '2019-03-26 16:59:24.000000', 100, 'Y', '2019-03-26 16:59:24.000000', 100);
-- 2019-03-26T19:07:10.767
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_ImpFormat_Row SET DataFormat='yyyyMMdd',Updated=TO_TIMESTAMP('2019-03-26 19:07:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ImpFormat_Row_ID=541080
;
update ad_impformat_row
set seqno = seqno+1, startno = startno+1
where AD_ImpFormat_ID=540032;
|
<reponame>jasarsoft/spark-backend
--zdatak 1
SELECT worker_name AS "Ime",
worker_lastname AS "Prezime"
FROM workers
WHERE worker_name LIKE "%a" AND salary > 600
--Zadatak 3
SELECT COUNT(w.id_worker) AS "<NAME>",
d.department_name AS "Naziv"
FROM workers AS w JOIN departments AS d
ON w.id_department = d.id_department
GROUP BY d.id_department
ORDER BY 1 DESC
--zadatak 4
SELECT COUNT(w.id_worker) AS "<NAME>",
IFNULL(d.department_name, "N/A") AS "Naziv"
FROM workers AS w
LEFT JOIN departments AS d
ON w.id_department = d.id_department
GROUP BY d.id_department
ORDER BY 1 DESC
--zadatak 5
SELECT COUNT(w.id_worker) AS "<NAME>",
IFNULL(d.department_name, "N/A") AS "Naziv"
FROM workers AS w
LEFT JOIN departments AS d
ON w.id_department = d.id_department
GROUP BY d.id_department
HAVING COUNT(w.id_worker) > 2
ORDER BY 1 DESC
--zadatak 6
SELECT COUNT(w.id_worker) AS "<NAME>",
IFNULL(d.department_name, "N/A") AS "Naziv",
MIN(salary) AS "Minimalna plata",
MAX(salary) AS "Maksimalna plata"
FROM workers AS w
LEFT JOIN departments AS d
ON w.id_department = d.id_department
GROUP BY d.id_department
ORDER BY 1 DESC
SELECT CONCAT(w.worker_name, ' ', w.worker_lastname) AS "<NAME>"
FROM workers AS w
LEFT JOIN departments AS d
ON w.id_department = d.id_department
WHERE d.department_name IN("Prodaja", "Support")
SELECT CONCAT(w.worker_name, ' ', w.worker_lastname) AS "<NAME>",
YEAR(w.worker_since_datetime) AS "Godina"
FROM workers AS w
LEFT JOIN departments AS d
ON w.id_department = d.id_department
WHERE YEAR(w.worker_since_datetime) = 2014
--zadatak 10
SELECT d.department_name
FROM workers AS w RIGHT JOIN departments AS d
ON w.id_department = d.id_department
WHERE w.id_worker IS NULL
GROUP BY d.department_name
SELECT d.department_name AS "<NAME>",
AVG(w.salary) AS "Prosjecna plata"
FROM workers AS w LEFT JOIN departments AS d
ON w.id_department = d.id_department
GROUP BY d.id_department
HAVING AVG(w.salary) > 660
SELECT COUNT(DISTINCT(w.worker_name)) AS "<NAME>"
FROM workers AS w LEFT JOIN departments AS d
ON w.id_department = d.id_department
ORDER BY w.worker_name
SELECT d.department_name AS "Odjel",
c.city_name AS "Grad",
AVG(w.salary) AS "Prosjecna plata"
FROM workers AS w JOIN cities AS c
ON w.id_city = c.id_city
JOIN departments AS d
ON w.id_department = d.id_department
GROUP BY c.id_city, d.id_department
SELECT d.department_name AS "Odjel",
c.city_name AS "Grad",
AVG(w.salary) AS "Prosjecna plata"
FROM workers AS w JOIN cities AS c
ON w.id_city = c.id_city
JOIN departments AS d
ON w.id_department = d.id_department
WHERE c.city_name LIKE "Mostar"
GROUP BY c.id_city, d.id_department
|
SET SEARCH_PATH = barlomgdbmetamodel;
----------------
-- VertexType --
----------------
-- Create / Update
DROP FUNCTION IF EXISTS UpsertVertexType( newName UUID, newName NAME, newSummary VARCHAR );
CREATE FUNCTION UpsertVertexType( newUuid UUID, newName NAME, newSummary VARCHAR )
RETURNS BIGINT
AS $$
INSERT INTO CHANGE ( type, elementUuid, dateTime, details )
VALUES ( 'UpsertVertexType', newUuid, current_timestamp,
('{ "uuid":"' || newUuid || '", "name":"' || newName || '", "summary":"' || newSummary || '"}')::jsonb );
WITH Affected AS (
INSERT INTO VertexType
( uuid, name, summary )
VALUES ( newUuid, newName, newSummary )
ON CONFLICT ( uuid ) DO
UPDATE
SET name = EXCLUDED.name,
summary = EXCLUDED.summary
RETURNING 1
)
SELECT COUNT(*) FROM Affected;
$$
LANGUAGE 'sql';
-- Delete
DROP FUNCTION IF EXISTS DeleteVertexType( oldUuid UUID );
CREATE FUNCTION DeleteVertexType( oldUuid UUID )
RETURNS BIGINT
AS $$
INSERT INTO CHANGE ( type, elementUuid, dateTime, details )
VALUES ( 'DeleteVertexType', oldUuid, current_timestamp,
('{ "uuid":"' || oldUuid || '"}')::jsonb );
WITH Affected AS (
DELETE
FROM VertexType
WHERE uuid = oldUuid
RETURNING 1
)
SELECT COUNT(*) FROM Affected;
$$
LANGUAGE 'sql';
-- Record Type
DROP TYPE IF EXISTS VertexTypeRecord CASCADE;
CREATE TYPE VertexTypeRecord AS
( uuid UUID, name NAME, summary VARCHAR );
-- Query by UUID
CREATE FUNCTION FindVertexTypeByName( queryName NAME )
RETURNS SETOF VertexTypeRecord
AS $$
SELECT uuid, name, summary
FROM VertexType
WHERE name = queryName;
$$
LANGUAGE 'sql';
-- Query by Name
CREATE FUNCTION FindVertexTypeByUuid( queryUuid UUID )
RETURNS SETOF VertexTypeRecord
AS $$
SELECT uuid, name, summary
FROM VertexType
WHERE uuid = queryUuid;
$$
LANGUAGE 'sql';
-- Query All
CREATE FUNCTION FindVertexTypesAll()
RETURNS SETOF VertexTypeRecord
AS $$
SELECT uuid, name, summary
FROM VertexType
ORDER BY name;
$$
LANGUAGE 'sql';
-- Sample Data for early testing
SELECT * FROM UpsertVertexType ( '2688a1dc-ab49-7fb6-7595-a28faba63c4f', 'VertexType1', 'The first vertex type' );
SELECT * FROM UpsertVertexType ( 'af576616-b593-4436-de54-f6f0ebbfbd30', 'VertexType2', 'The second vertex type' );
SELECT * FROM UpsertVertexType ( 'd199be0f-52ec-8a56-8ef2-a3abbe6cde65', 'VertexType3', 'Number three' );
SELECT * FROM UpsertVertexType ( '05562007-9be3-cf85-ab21-fc291f21e86c', 'VertexType4', 'The fourth vertex type' );
SELECT * FROM UpsertVertexType ( '506c214f-cee0-e946-7501-629ffa4b25e3', 'VertexType5', 'Another one' );
SELECT * FROM UpsertVertexType ( '463817bf-4194-8717-3ad7-cd75b00b4dec', 'VertexType6', 'The last' );
|
--Query Using CTE
with cte as
(
select b.ShippedDate,b.OrderID,
cast(Sum(UnitPrice*Quantity*(1-Discount)) as decimal(10,2)) as Total
from [Order Details] a
join Orders b
on a.OrderID=b.OrderID
Where b.ShippedDate is not null
and ShippedDate between '1996-12-24' and '1997-09-30'
group by b.ShippedDate,b.OrderID
)
select *, Year(cte.ShippedDate) Year from cte order by cte.ShippedDate;
--Query Using Correlated Sub Query
Select cast(ShippedDate as date) as ShippedDate,a.OrderId, b.Total,Year(ShippedDate) Year
From
(
Select OrderID,
Cast(Sum(UnitPrice*Quantity*(1-discount)) as decimal(10,2)) as Total
from [Order Details]
group by OrderID
) as b
join Orders a on a.OrderID=b.OrderID
Where
ShippedDate between '1996-05-01' and '1997-05-30'
And
ShippedDate is not null
Order by ShippedDate
|
<gh_stars>0
/*
Navicat MySQL Data Transfer
Source Server : mysql
Source Server Version : 50171
Source Host : localhost:3306
Source Database : egies
Target Server Type : MYSQL
Target Server Version : 50171
File Encoding : 65001
Date: 2017-07-14 17:15:45
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for t_classifications
-- ----------------------------
DROP TABLE IF EXISTS `t_classifications`;
CREATE TABLE `t_classifications` (
`id` int(255) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`type` int(255) NOT NULL,
`level` int(255) NOT NULL,
`mark` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=362 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_classifications
-- ----------------------------
INSERT INTO `t_classifications` VALUES ('1', '应急', '1', '0', null);
INSERT INTO `t_classifications` VALUES ('2', '自然灾害', '10', '0', null);
INSERT INTO `t_classifications` VALUES ('3', '水旱灾害', '100', '0', null);
INSERT INTO `t_classifications` VALUES ('4', '洪涝灾', '1000', '0', null);
INSERT INTO `t_classifications` VALUES ('5', '旱灾', '1001', '0', null);
INSERT INTO `t_classifications` VALUES ('6', '气象灾害', '101', '0', null);
INSERT INTO `t_classifications` VALUES ('7', '暴雨', '1010', '0', null);
INSERT INTO `t_classifications` VALUES ('8', '雨涝', '1011', '0', null);
INSERT INTO `t_classifications` VALUES ('9', '干旱', '1012', '0', null);
INSERT INTO `t_classifications` VALUES ('10', '干热风', '1013', '0', null);
INSERT INTO `t_classifications` VALUES ('11', '高温', '1014', '0', null);
INSERT INTO `t_classifications` VALUES ('12', '热浪', '1015', '0', null);
INSERT INTO `t_classifications` VALUES ('13', '热带气旋', '1016', '0', null);
INSERT INTO `t_classifications` VALUES ('14', '冷害', '1017', '0', null);
INSERT INTO `t_classifications` VALUES ('15', '冻害', '1018', '0', null);
INSERT INTO `t_classifications` VALUES ('16', '冻雨', '1019', '0', null);
INSERT INTO `t_classifications` VALUES ('17', '结冰', '10110', '0', null);
INSERT INTO `t_classifications` VALUES ('18', '雪害', '10111', '0', null);
INSERT INTO `t_classifications` VALUES ('19', '雹害', '10112', '0', null);
INSERT INTO `t_classifications` VALUES ('20', '风害', '10113', '0', null);
INSERT INTO `t_classifications` VALUES ('21', '龙卷风', '10114', '0', null);
INSERT INTO `t_classifications` VALUES ('22', '雷电', '10115', '0', null);
INSERT INTO `t_classifications` VALUES ('23', '连阴雨', '10116', '0', null);
INSERT INTO `t_classifications` VALUES ('24', '淫雨', '10117', '0', null);
INSERT INTO `t_classifications` VALUES ('25', '浓雾', '10118', '0', null);
INSERT INTO `t_classifications` VALUES ('26', '低空风切变', '10119', '0', null);
INSERT INTO `t_classifications` VALUES ('27', '地震灾害', '102', '0', null);
INSERT INTO `t_classifications` VALUES ('28', '地震', '1020', '1', null);
INSERT INTO `t_classifications` VALUES ('29', '地震', '1021', '2', null);
INSERT INTO `t_classifications` VALUES ('30', '地震', '1022', '3', null);
INSERT INTO `t_classifications` VALUES ('31', '地震', '1023', '4', null);
INSERT INTO `t_classifications` VALUES ('32', '地质灾害', '103', '0', null);
INSERT INTO `t_classifications` VALUES ('33', '崩塌', '1030', '0', null);
INSERT INTO `t_classifications` VALUES ('34', '滑坡', '1031', '0', null);
INSERT INTO `t_classifications` VALUES ('35', '泥石流', '1032', '0', null);
INSERT INTO `t_classifications` VALUES ('36', '地面塌陷', '1033', '0', null);
INSERT INTO `t_classifications` VALUES ('37', '地裂缝', '1034', '0', null);
INSERT INTO `t_classifications` VALUES ('38', '水土流失', '1035', '0', null);
INSERT INTO `t_classifications` VALUES ('39', '沙尘暴', '1036', '0', null);
INSERT INTO `t_classifications` VALUES ('40', '沼泽化', '1037', '0', null);
INSERT INTO `t_classifications` VALUES ('41', '土壤盐碱化', '1038', '0', null);
INSERT INTO `t_classifications` VALUES ('42', '火山', '1039', '0', null);
INSERT INTO `t_classifications` VALUES ('43', '地热害', '10310', '0', null);
INSERT INTO `t_classifications` VALUES ('44', '海洋灾害', '104', '0', null);
INSERT INTO `t_classifications` VALUES ('45', '风暴潮', '1040', '0', null);
INSERT INTO `t_classifications` VALUES ('46', '海浪', '1041', '0', null);
INSERT INTO `t_classifications` VALUES ('47', '海冰', '1042', '0', null);
INSERT INTO `t_classifications` VALUES ('48', '海啸', '1043', '0', null);
INSERT INTO `t_classifications` VALUES ('49', '台风', '1044', '0', null);
INSERT INTO `t_classifications` VALUES ('50', '飓风', '1045', '0', null);
INSERT INTO `t_classifications` VALUES ('51', '赤潮', '1046', '0', null);
INSERT INTO `t_classifications` VALUES ('52', '绿潮', '1047', '0', null);
INSERT INTO `t_classifications` VALUES ('53', '海平面变化', '1048', '0', null);
INSERT INTO `t_classifications` VALUES ('54', '海岸侵蚀', '1049', '0', null);
INSERT INTO `t_classifications` VALUES ('55', '海水入侵', '10410', '0', null);
INSERT INTO `t_classifications` VALUES ('56', '土壤盐渍化', '10411', '0', null);
INSERT INTO `t_classifications` VALUES ('57', '咸潮入侵', '10412', '0', null);
INSERT INTO `t_classifications` VALUES ('58', '生物灾害', '105', '0', null);
INSERT INTO `t_classifications` VALUES ('59', '农作物病虫害', '1050', '0', null);
INSERT INTO `t_classifications` VALUES ('60', '蝗灾', '1052', '0', null);
INSERT INTO `t_classifications` VALUES ('61', '鼠灾', '1053', '0', null);
INSERT INTO `t_classifications` VALUES ('62', '森林灾害', '106', '0', null);
INSERT INTO `t_classifications` VALUES ('63', '病害', '1060', '0', null);
INSERT INTO `t_classifications` VALUES ('64', '幼苗猝倒病', '10600', '0', null);
INSERT INTO `t_classifications` VALUES ('65', '立枯病', '10601', '0', null);
INSERT INTO `t_classifications` VALUES ('66', '死苗', '10602', '0', null);
INSERT INTO `t_classifications` VALUES ('67', '松类疱锈病', '10603', '0', null);
INSERT INTO `t_classifications` VALUES ('68', '烂皮病', '10604', '0', null);
INSERT INTO `t_classifications` VALUES ('69', '枯萎病', '10605', '0', null);
INSERT INTO `t_classifications` VALUES ('70', '丛枝病', '10606', '0', null);
INSERT INTO `t_classifications` VALUES ('71', '叶斑病', '10607', '0', null);
INSERT INTO `t_classifications` VALUES ('72', '立木腐朽', '10608', '0', null);
INSERT INTO `t_classifications` VALUES ('73', '虫害', '1061', '0', null);
INSERT INTO `t_classifications` VALUES ('74', '地老虎', '10610', '0', null);
INSERT INTO `t_classifications` VALUES ('75', '蛴螬', '10611', '0', null);
INSERT INTO `t_classifications` VALUES ('76', '金针虫', '10612', '0', null);
INSERT INTO `t_classifications` VALUES ('77', '种蝇', '10613', '0', null);
INSERT INTO `t_classifications` VALUES ('78', '蝼蛄', '10614', '0', null);
INSERT INTO `t_classifications` VALUES ('79', '小蠹', '10615', '0', null);
INSERT INTO `t_classifications` VALUES ('80', '天牛', '10616', '0', null);
INSERT INTO `t_classifications` VALUES ('81', '吉丁虫', '10617', '0', null);
INSERT INTO `t_classifications` VALUES ('82', '象甲', '10618', '0', null);
INSERT INTO `t_classifications` VALUES ('83', '木蠹蛾', '10619', '0', null);
INSERT INTO `t_classifications` VALUES ('84', '透翅蛾', '106110', '0', null);
INSERT INTO `t_classifications` VALUES ('85', '蚜虫', '106111', '0', null);
INSERT INTO `t_classifications` VALUES ('86', '蚧类', '106112', '0', null);
INSERT INTO `t_classifications` VALUES ('87', '粉虱', '106113', '0', null);
INSERT INTO `t_classifications` VALUES ('88', '木虱', '106114', '0', null);
INSERT INTO `t_classifications` VALUES ('89', '叶蝉', '106115', '0', null);
INSERT INTO `t_classifications` VALUES ('90', '枯叶蛾', '106116', '0', null);
INSERT INTO `t_classifications` VALUES ('91', '毒蛾', '106117', '0', null);
INSERT INTO `t_classifications` VALUES ('92', '尺蛾', '106118', '0', null);
INSERT INTO `t_classifications` VALUES ('93', '舟蛾', '106119', '0', null);
INSERT INTO `t_classifications` VALUES ('94', '袋蛾', '106120', '0', null);
INSERT INTO `t_classifications` VALUES ('95', '刺蛾', '106121', '0', null);
INSERT INTO `t_classifications` VALUES ('96', '潜叶蛾', '106122', '0', null);
INSERT INTO `t_classifications` VALUES ('97', '卷蛾', '106123', '0', null);
INSERT INTO `t_classifications` VALUES ('98', '斑蛾', '106124', '0', null);
INSERT INTO `t_classifications` VALUES ('99', '叶甲', '106125', '0', null);
INSERT INTO `t_classifications` VALUES ('100', '叶蜂', '106126', '0', null);
INSERT INTO `t_classifications` VALUES ('101', '竹蝗', '106127', '0', null);
INSERT INTO `t_classifications` VALUES ('102', '螟蛾', '106128', '0', null);
INSERT INTO `t_classifications` VALUES ('103', '卷蛾', '106129', '0', null);
INSERT INTO `t_classifications` VALUES ('104', '麦蛾', '106130', '0', null);
INSERT INTO `t_classifications` VALUES ('105', '举肢蛾', '106131', '0', null);
INSERT INTO `t_classifications` VALUES ('106', '象虫', '106132', '0', null);
INSERT INTO `t_classifications` VALUES ('107', '小蜂', '106133', '0', null);
INSERT INTO `t_classifications` VALUES ('108', '花蝇', '106134', '0', null);
INSERT INTO `t_classifications` VALUES ('109', '瘿蚊', '106135', '0', null);
INSERT INTO `t_classifications` VALUES ('110', '火灾', '1062', '0', null);
INSERT INTO `t_classifications` VALUES ('111', '鸟兽害', '1063', '0', null);
INSERT INTO `t_classifications` VALUES ('112', '大林姬鼠', '10630', '0', null);
INSERT INTO `t_classifications` VALUES ('113', '小林姬鼠', '10631', '0', null);
INSERT INTO `t_classifications` VALUES ('114', '棕背', '10632', '0', null);
INSERT INTO `t_classifications` VALUES ('115', '红背', '10633', '0', null);
INSERT INTO `t_classifications` VALUES ('116', '东方田鼠', '10634', '0', null);
INSERT INTO `t_classifications` VALUES ('117', '花鼠', '10635', '0', null);
INSERT INTO `t_classifications` VALUES ('118', '中华竹鼠', '10636', '0', null);
INSERT INTO `t_classifications` VALUES ('119', '银星竹鼠', '10637', '0', null);
INSERT INTO `t_classifications` VALUES ('120', '大竹鼠', '10638', '0', null);
INSERT INTO `t_classifications` VALUES ('121', '草兔', '10639', '0', null);
INSERT INTO `t_classifications` VALUES ('122', '野猪', '106310', '0', null);
INSERT INTO `t_classifications` VALUES ('123', '锡嘴雀', '106311', '0', null);
INSERT INTO `t_classifications` VALUES ('124', '红交嘴雀 ', '106312', '0', null);
INSERT INTO `t_classifications` VALUES ('125', '星鸦 ', '106313', '0', null);
INSERT INTO `t_classifications` VALUES ('126', '松鸦', '106314', '0', null);
INSERT INTO `t_classifications` VALUES ('127', '气象灾害', '1064', '0', null);
INSERT INTO `t_classifications` VALUES ('128', '低温害', '10640', '0', null);
INSERT INTO `t_classifications` VALUES ('129', '冻害', '106400', '0', null);
INSERT INTO `t_classifications` VALUES ('130', '寒害', '106401', '0', null);
INSERT INTO `t_classifications` VALUES ('131', '冻拔', '106402', '0', null);
INSERT INTO `t_classifications` VALUES ('132', '冻举', '106403', '0', null);
INSERT INTO `t_classifications` VALUES ('133', '冻裂', '106404', '0', null);
INSERT INTO `t_classifications` VALUES ('134', '干旱', '106405', '0', '土壤结冻造成的生理干旱');
INSERT INTO `t_classifications` VALUES ('135', '高温害', '10641', '0', null);
INSERT INTO `t_classifications` VALUES ('136', '干旱', '10642', '0', null);
INSERT INTO `t_classifications` VALUES ('137', '洪涝', '10643', '0', null);
INSERT INTO `t_classifications` VALUES ('138', '雪害', '10644', '0', null);
INSERT INTO `t_classifications` VALUES ('139', '风害', '10645', '0', null);
INSERT INTO `t_classifications` VALUES ('140', '盐风害系', '10646', '0', null);
INSERT INTO `t_classifications` VALUES ('141', '冻雨', '10647', '0', null);
INSERT INTO `t_classifications` VALUES ('142', '雨淞', '10648', '0', null);
INSERT INTO `t_classifications` VALUES ('143', '雹害', '10649', '0', null);
INSERT INTO `t_classifications` VALUES ('144', '气象污染害', '10650', '0', null);
INSERT INTO `t_classifications` VALUES ('145', '其他', '107', '0', null);
INSERT INTO `t_classifications` VALUES ('146', '事故灾难', '11', '0', null);
INSERT INTO `t_classifications` VALUES ('147', '工矿商贸等企业的各类安全事故', '110', '0', null);
INSERT INTO `t_classifications` VALUES ('148', '物体打击', '1100', '0', null);
INSERT INTO `t_classifications` VALUES ('149', '车辆伤害', '1101', '0', null);
INSERT INTO `t_classifications` VALUES ('150', '机械伤害', '1102', '0', null);
INSERT INTO `t_classifications` VALUES ('151', '起重伤害', '1103', '0', null);
INSERT INTO `t_classifications` VALUES ('152', '触电', '1104', '0', null);
INSERT INTO `t_classifications` VALUES ('153', '火灾', '1105', '0', null);
INSERT INTO `t_classifications` VALUES ('154', '灼烫', '1106', '0', null);
INSERT INTO `t_classifications` VALUES ('155', '淹溺', '1107', '0', null);
INSERT INTO `t_classifications` VALUES ('156', '高处坠落', '1108', '0', null);
INSERT INTO `t_classifications` VALUES ('157', '坍塌', '1109', '0', null);
INSERT INTO `t_classifications` VALUES ('158', '冒顶片帮', '11010', '0', null);
INSERT INTO `t_classifications` VALUES ('159', '透水', '11011', '0', null);
INSERT INTO `t_classifications` VALUES ('160', '放炮', '11012', '0', null);
INSERT INTO `t_classifications` VALUES ('161', '火药爆炸', '11013', '0', null);
INSERT INTO `t_classifications` VALUES ('162', '瓦斯爆炸', '11014', '0', null);
INSERT INTO `t_classifications` VALUES ('163', '锅炉爆炸', '11015', '0', null);
INSERT INTO `t_classifications` VALUES ('164', '容器爆炸', '11016', '0', null);
INSERT INTO `t_classifications` VALUES ('165', '其他爆炸', '11017', '0', null);
INSERT INTO `t_classifications` VALUES ('166', '中毒', '11018', '0', null);
INSERT INTO `t_classifications` VALUES ('167', '窒息', '11019', '0', null);
INSERT INTO `t_classifications` VALUES ('168', '其他伤害', '11020', '0', null);
INSERT INTO `t_classifications` VALUES ('169', '交通运输事故', '111', '0', null);
INSERT INTO `t_classifications` VALUES ('170', '直行', '1110', '0', null);
INSERT INTO `t_classifications` VALUES ('171', '追尾', '1111', '0', null);
INSERT INTO `t_classifications` VALUES ('172', '超车', '1112', '0', null);
INSERT INTO `t_classifications` VALUES ('173', '左转弯', '1113', '0', null);
INSERT INTO `t_classifications` VALUES ('174', '右转弯', '1114', '0', null);
INSERT INTO `t_classifications` VALUES ('175', '窄道', '1115', '0', null);
INSERT INTO `t_classifications` VALUES ('176', '弯道', '1116', '0', null);
INSERT INTO `t_classifications` VALUES ('177', '坡道', '1117', '0', null);
INSERT INTO `t_classifications` VALUES ('178', '会车', '1118', '0', null);
INSERT INTO `t_classifications` VALUES ('179', '超车', '1119', '0', null);
INSERT INTO `t_classifications` VALUES ('180', '停车', '11110', '0', null);
INSERT INTO `t_classifications` VALUES ('181', '公共设施和设备事故', '112', '0', null);
INSERT INTO `t_classifications` VALUES ('182', '环境污染和生态破坏事件', '113', '0', null);
INSERT INTO `t_classifications` VALUES ('183', '大气污染', '1130', '0', null);
INSERT INTO `t_classifications` VALUES ('184', '水体污染', '1131', '0', null);
INSERT INTO `t_classifications` VALUES ('185', '土壤污染', '1132', '0', null);
INSERT INTO `t_classifications` VALUES ('186', '噪声污染', '1133', '0', null);
INSERT INTO `t_classifications` VALUES ('187', '农药污染', '1134', '0', null);
INSERT INTO `t_classifications` VALUES ('188', '辐射污染', '1135', '0', null);
INSERT INTO `t_classifications` VALUES ('189', '热污染', '1136', '0', null);
INSERT INTO `t_classifications` VALUES ('190', '其他', '114', '0', null);
INSERT INTO `t_classifications` VALUES ('191', '公共卫生事件', '12', '0', null);
INSERT INTO `t_classifications` VALUES ('192', '传染病疫情', '120', '0', null);
INSERT INTO `t_classifications` VALUES ('193', '鼠疫', '1200', '0', null);
INSERT INTO `t_classifications` VALUES ('194', '霍乱', '1201', '0', null);
INSERT INTO `t_classifications` VALUES ('195', '肺结核', '1202', '0', null);
INSERT INTO `t_classifications` VALUES ('196', '肝炎', '1203', '0', null);
INSERT INTO `t_classifications` VALUES ('197', '痢疾', '1204', '0', null);
INSERT INTO `t_classifications` VALUES ('198', '伤寒', '1205', '0', null);
INSERT INTO `t_classifications` VALUES ('199', '副伤寒', '1206', '0', null);
INSERT INTO `t_classifications` VALUES ('200', '艾滋病', '1207', '0', null);
INSERT INTO `t_classifications` VALUES ('201', '淋病', '1208', '0', null);
INSERT INTO `t_classifications` VALUES ('202', '梅毒', '1209', '0', null);
INSERT INTO `t_classifications` VALUES ('203', '脊髓灰质炎', '12010', '0', null);
INSERT INTO `t_classifications` VALUES ('204', '麻疹', '12011', '0', null);
INSERT INTO `t_classifications` VALUES ('205', '百日咳', '12012', '0', null);
INSERT INTO `t_classifications` VALUES ('206', '白喉', '12013', '0', null);
INSERT INTO `t_classifications` VALUES ('207', '脑脊髓膜炎', '12014', '0', null);
INSERT INTO `t_classifications` VALUES ('208', '猩红热', '12015', '0', null);
INSERT INTO `t_classifications` VALUES ('209', '出血热', '12016', '0', null);
INSERT INTO `t_classifications` VALUES ('210', '狂犬病', '12017', '0', null);
INSERT INTO `t_classifications` VALUES ('211', '钩端螺旋体病', '12018', '0', null);
INSERT INTO `t_classifications` VALUES ('212', '布鲁氏菌病', '12019', '0', null);
INSERT INTO `t_classifications` VALUES ('213', '炭疽', '12020', '0', null);
INSERT INTO `t_classifications` VALUES ('214', '斑疹伤寒', '12021', '0', null);
INSERT INTO `t_classifications` VALUES ('215', '乙型脑炎', '12022', '0', null);
INSERT INTO `t_classifications` VALUES ('216', '黑热病', '12023', '0', null);
INSERT INTO `t_classifications` VALUES ('217', '疟疾', '12024', '0', null);
INSERT INTO `t_classifications` VALUES ('218', '登革热', '12025', '0', null);
INSERT INTO `t_classifications` VALUES ('219', '禽流感', '12026', '0', null);
INSERT INTO `t_classifications` VALUES ('220', '非典型肺炎', '12027', '0', null);
INSERT INTO `t_classifications` VALUES ('221', '甲型H1N1流感', '12028', '0', null);
INSERT INTO `t_classifications` VALUES ('222', '血吸虫病', '12029', '0', null);
INSERT INTO `t_classifications` VALUES ('223', '丝虫病', '12030', '0', null);
INSERT INTO `t_classifications` VALUES ('224', '包虫病', '12031', '0', null);
INSERT INTO `t_classifications` VALUES ('225', '麻风病', '12032', '0', null);
INSERT INTO `t_classifications` VALUES ('226', '感冒', '12033', '0', null);
INSERT INTO `t_classifications` VALUES ('227', '腮腺炎', '12034', '0', null);
INSERT INTO `t_classifications` VALUES ('228', '风疹', '12035', '0', null);
INSERT INTO `t_classifications` VALUES ('229', '破伤风', '12036', '0', null);
INSERT INTO `t_classifications` VALUES ('230', '结膜炎', '12037', '0', null);
INSERT INTO `t_classifications` VALUES ('231', '腹泻', '12038', '0', null);
INSERT INTO `t_classifications` VALUES ('232', '手足口病', '12039', '0', null);
INSERT INTO `t_classifications` VALUES ('233', '尿道炎', '12040', '0', null);
INSERT INTO `t_classifications` VALUES ('234', '尖锐湿疣', '12041', '0', null);
INSERT INTO `t_classifications` VALUES ('235', '生殖器疱疹', '12042', '0', null);
INSERT INTO `t_classifications` VALUES ('236', '水痘', '12043', '0', null);
INSERT INTO `t_classifications` VALUES ('237', '肝吸虫病', '12044', '0', null);
INSERT INTO `t_classifications` VALUES ('238', '生殖道沙眼衣原体感染', '12045', '0', null);
INSERT INTO `t_classifications` VALUES ('239', '恙虫病', '12046', '0', null);
INSERT INTO `t_classifications` VALUES ('240', '森林脑炎', '12047', '0', null);
INSERT INTO `t_classifications` VALUES ('241', '结核性胸膜炎', '12048', '0', null);
INSERT INTO `t_classifications` VALUES ('242', '猪链球菌病', '12049', '0', null);
INSERT INTO `t_classifications` VALUES ('243', '细胞无形体病', '12050', '0', null);
INSERT INTO `t_classifications` VALUES ('244', '肺炎', '12051', '0', null);
INSERT INTO `t_classifications` VALUES ('245', '不明原因疾病', '12052', '0', null);
INSERT INTO `t_classifications` VALUES ('246', '发热伴血小板减少综合征', '12053', '0', null);
INSERT INTO `t_classifications` VALUES ('247', 'AFP', '12054', '0', null);
INSERT INTO `t_classifications` VALUES ('248', '群体性不明原因疾病', '121', '0', null);
INSERT INTO `t_classifications` VALUES ('249', '食品安全', '122', '0', null);
INSERT INTO `t_classifications` VALUES ('250', '职业危害', '123', '0', null);
INSERT INTO `t_classifications` VALUES ('251', '粉尘', '1230', '0', null);
INSERT INTO `t_classifications` VALUES ('252', '化学因素', '1231', '0', null);
INSERT INTO `t_classifications` VALUES ('253', '物理因素', '1232', '0', null);
INSERT INTO `t_classifications` VALUES ('254', '放射性因素', '1233', '0', null);
INSERT INTO `t_classifications` VALUES ('255', '生物因素', '1234', '0', null);
INSERT INTO `t_classifications` VALUES ('256', '其他因素', '1235', '0', null);
INSERT INTO `t_classifications` VALUES ('257', '动物疫情', '124', '0', null);
INSERT INTO `t_classifications` VALUES ('258', '口蹄疫', '1240', '0', null);
INSERT INTO `t_classifications` VALUES ('259', '猪水泡病', '1241', '0', null);
INSERT INTO `t_classifications` VALUES ('260', '猪瘟', '1242', '0', null);
INSERT INTO `t_classifications` VALUES ('261', '非洲猪瘟', '1243', '0', null);
INSERT INTO `t_classifications` VALUES ('262', '猪蓝耳病', '1244', '0', null);
INSERT INTO `t_classifications` VALUES ('263', '非洲马瘟', '1245', '0', null);
INSERT INTO `t_classifications` VALUES ('264', '牛瘟', '1246', '0', null);
INSERT INTO `t_classifications` VALUES ('265', '胸膜肺炎', '1247', '0', null);
INSERT INTO `t_classifications` VALUES ('266', '牛海绵状脑病', '1248', '0', null);
INSERT INTO `t_classifications` VALUES ('267', '痒病', '1249', '0', null);
INSERT INTO `t_classifications` VALUES ('268', '蓝舌病', '12410', '0', null);
INSERT INTO `t_classifications` VALUES ('269', '小反刍兽疫', '12411', '0', null);
INSERT INTO `t_classifications` VALUES ('270', '绵羊痘', '12412', '0', null);
INSERT INTO `t_classifications` VALUES ('271', '山羊痘', '12413', '0', null);
INSERT INTO `t_classifications` VALUES ('272', '禽流感', '12414', '0', null);
INSERT INTO `t_classifications` VALUES ('273', '新城疫', '12415', '0', null);
INSERT INTO `t_classifications` VALUES ('274', '鲤春病毒血症', '12416', '0', null);
INSERT INTO `t_classifications` VALUES ('275', '白斑综合征', '12417', '0', null);
INSERT INTO `t_classifications` VALUES ('276', '狂犬病', '12418', '0', null);
INSERT INTO `t_classifications` VALUES ('277', '布鲁氏菌病', '12419', '0', null);
INSERT INTO `t_classifications` VALUES ('278', '炭疽', '12420', '0', null);
INSERT INTO `t_classifications` VALUES ('279', '伪狂犬病', '12421', '0', null);
INSERT INTO `t_classifications` VALUES ('280', '魏氏梭菌病', '12422', '0', null);
INSERT INTO `t_classifications` VALUES ('281', '副结核病', '12423', '0', null);
INSERT INTO `t_classifications` VALUES ('282', '弓形虫病', '12424', '0', null);
INSERT INTO `t_classifications` VALUES ('283', '棘球蚴病', '12425', '0', null);
INSERT INTO `t_classifications` VALUES ('284', '钩端螺旋体病', '12426', '0', null);
INSERT INTO `t_classifications` VALUES ('285', '牛结核病', '12427', '0', null);
INSERT INTO `t_classifications` VALUES ('286', '鼻气管炎', '12428', '0', null);
INSERT INTO `t_classifications` VALUES ('287', '卡他热', '12429', '0', null);
INSERT INTO `t_classifications` VALUES ('288', '牛白血病', '12430', '0', null);
INSERT INTO `t_classifications` VALUES ('289', '败血病', '12431', '0', null);
INSERT INTO `t_classifications` VALUES ('290', '梨形虫病', '12432', '0', null);
INSERT INTO `t_classifications` VALUES ('291', '牛焦虫病', '12433', '0', null);
INSERT INTO `t_classifications` VALUES ('292', '牛锥虫病', '12434', '0', null);
INSERT INTO `t_classifications` VALUES ('293', '日本吸血虫病', '12435', '0', null);
INSERT INTO `t_classifications` VALUES ('294', '关节炎', '12436', '0', null);
INSERT INTO `t_classifications` VALUES ('295', '脑炎', '12437', '0', null);
INSERT INTO `t_classifications` VALUES ('296', '梅迪-维斯纳病', '12438', '0', null);
INSERT INTO `t_classifications` VALUES ('297', '猪蓝耳病', '12439', '0', null);
INSERT INTO `t_classifications` VALUES ('298', '猪乙型脑炎', '12440', '0', null);
INSERT INTO `t_classifications` VALUES ('299', '猪细小病毒病', '12441', '0', null);
INSERT INTO `t_classifications` VALUES ('300', '猪丹毒', '12442', '0', null);
INSERT INTO `t_classifications` VALUES ('301', '猪肺疫', '12443', '0', null);
INSERT INTO `t_classifications` VALUES ('302', '猪链球菌病', '12444', '0', null);
INSERT INTO `t_classifications` VALUES ('303', '鼻炎', '12445', '0', null);
INSERT INTO `t_classifications` VALUES ('304', '猪支原体肺炎', '12446', '0', null);
INSERT INTO `t_classifications` VALUES ('305', '旋毛虫病', '12447', '0', null);
INSERT INTO `t_classifications` VALUES ('306', '猪囊尾蚴病', '12448', '0', null);
INSERT INTO `t_classifications` VALUES ('307', '猪圆环病毒病', '12449', '0', null);
INSERT INTO `t_classifications` VALUES ('308', '副猪嗜血杆菌病。', '12450', '0', null);
INSERT INTO `t_classifications` VALUES ('309', '贫血', '12451', '0', null);
INSERT INTO `t_classifications` VALUES ('310', '淋巴管炎', '12452', '0', null);
INSERT INTO `t_classifications` VALUES ('311', '马鼻疽', '12453', '0', null);
INSERT INTO `t_classifications` VALUES ('312', '马巴贝斯虫病', '12454', '0', null);
INSERT INTO `t_classifications` VALUES ('313', '伊氏锥虫病', '12455', '0', null);
INSERT INTO `t_classifications` VALUES ('314', '喉气管炎', '12456', '0', null);
INSERT INTO `t_classifications` VALUES ('315', '支气管炎', '12457', '0', null);
INSERT INTO `t_classifications` VALUES ('316', '法氏囊病', '12458', '0', null);
INSERT INTO `t_classifications` VALUES ('317', '马立克氏病', '12459', '0', null);
INSERT INTO `t_classifications` VALUES ('318', '产蛋下降综合征', '12460', '0', null);
INSERT INTO `t_classifications` VALUES ('319', '禽白血病', '12461', '0', null);
INSERT INTO `t_classifications` VALUES ('320', '禽痘', '12462', '0', null);
INSERT INTO `t_classifications` VALUES ('321', '鸭瘟', '12463', '0', null);
INSERT INTO `t_classifications` VALUES ('322', '鸭病毒性肝炎', '12464', '0', null);
INSERT INTO `t_classifications` VALUES ('323', '鸭浆膜炎', '12465', '0', null);
INSERT INTO `t_classifications` VALUES ('324', '小鹅瘟', '12466', '0', null);
INSERT INTO `t_classifications` VALUES ('325', '禽霍乱', '12467', '0', null);
INSERT INTO `t_classifications` VALUES ('326', '鸡白痢', '12468', '0', null);
INSERT INTO `t_classifications` VALUES ('327', '禽伤寒', '12469', '0', null);
INSERT INTO `t_classifications` VALUES ('328', '鸡败血支原体感染', '12470', '0', null);
INSERT INTO `t_classifications` VALUES ('329', '鸡球虫病', '12471', '0', null);
INSERT INTO `t_classifications` VALUES ('330', '低致病性禽流感', '12472', '0', null);
INSERT INTO `t_classifications` VALUES ('331', '禽网状内皮组织增殖症。', '12473', '0', null);
INSERT INTO `t_classifications` VALUES ('332', '兔病毒性出血病', '12474', '0', null);
INSERT INTO `t_classifications` VALUES ('333', '兔粘液瘤病', '12475', '0', null);
INSERT INTO `t_classifications` VALUES ('334', '野兔热', '12476', '0', null);
INSERT INTO `t_classifications` VALUES ('335', '兔球虫病', '12477', '0', null);
INSERT INTO `t_classifications` VALUES ('336', '美洲幼虫腐臭病', '12478', '0', null);
INSERT INTO `t_classifications` VALUES ('337', '欧洲幼虫腐臭病', '12479', '0', null);
INSERT INTO `t_classifications` VALUES ('338', '草鱼出血病', '12480', '0', null);
INSERT INTO `t_classifications` VALUES ('339', '传染性脾肾坏死病', '12481', '0', null);
INSERT INTO `t_classifications` VALUES ('340', '锦鲤疱疹病毒病', '12482', '0', null);
INSERT INTO `t_classifications` VALUES ('341', '刺激隐核虫病', '12483', '0', null);
INSERT INTO `t_classifications` VALUES ('342', '淡水鱼细菌性败血症', '12484', '0', null);
INSERT INTO `t_classifications` VALUES ('343', '病毒性神经坏死病', '12485', '0', null);
INSERT INTO `t_classifications` VALUES ('344', '流行性造血器官坏死病', '12486', '0', null);
INSERT INTO `t_classifications` VALUES ('345', '斑点叉尾鮰病毒病', '12487', '0', null);
INSERT INTO `t_classifications` VALUES ('346', '传染性造血器官坏死病', '12488', '0', null);
INSERT INTO `t_classifications` VALUES ('347', '病毒性出血性败血症', '12489', '0', null);
INSERT INTO `t_classifications` VALUES ('348', '流行性溃疡综合征', '12490', '0', null);
INSERT INTO `t_classifications` VALUES ('349', '桃拉综合征', '12491', '0', null);
INSERT INTO `t_classifications` VALUES ('350', '黄头病', '12492', '0', null);
INSERT INTO `t_classifications` VALUES ('351', '罗氏沼虾白尾病', '12493', '0', null);
INSERT INTO `t_classifications` VALUES ('352', '对虾杆状病毒病', '12494', '0', null);
INSERT INTO `t_classifications` VALUES ('353', '传染性皮下和造血器官坏死病', '12495', '0', null);
INSERT INTO `t_classifications` VALUES ('354', '传染性肌肉坏死病', '12496', '0', null);
INSERT INTO `t_classifications` VALUES ('355', '其他', '125', '0', null);
INSERT INTO `t_classifications` VALUES ('356', '社会安全事件', '13', '0', null);
INSERT INTO `t_classifications` VALUES ('357', '恐怖袭击事件', '130', '0', null);
INSERT INTO `t_classifications` VALUES ('358', '经济安全事件', '131', '0', null);
INSERT INTO `t_classifications` VALUES ('359', '涉外突发事件', '132', '0', null);
INSERT INTO `t_classifications` VALUES ('360', '其他', '133', '0', null);
INSERT INTO `t_classifications` VALUES ('361', 'H7N9', '12054', '0', null);
|
CREATE TABLE engine (
en_id SERIAL PRIMARY KEY,
brand VARCHAR(100),
type VARCHAR(100)
);
CREATE TABLE transmission (
trans_id SERIAL PRIMARY KEY,
brand VARCHAR(100),
type VARCHAR(100)
);
CREATE TABLE carBody (
cb_id SERIAL PRIMARY KEY,
brand VARCHAR(100),
type VARCHAR(100)
);
CREATE TABLE car (
car_id SERIAL PRIMARY KEY,
brand VARCHAR(100),
en_id INTEGER REFERENCES engine(en_id),
trans_id INTEGER REFERENCES transmission(trans_id),
cb_id INTEGER REFERENCES carBody(cb_id)
); |
CREATE INDEX idx_base_disks_disk_alias ON base_disks (disk_alias);
|
<gh_stars>1-10
CREATE OR REPLACE FUNCTION zdb.vac_by_xmin(index regclass, type text, xmin bigint) RETURNS zdbquery PARALLEL SAFE STABLE STRICT LANGUAGE sql AS $$
/*
* docs with aborted xmins
*/
SELECT dsl.and(
dsl.range(field=>'zdb_xmin', lt=>xmin),
dsl.terms_lookup('zdb_xmin', zdb.index_name(index), type, 'zdb_aborted_xids', 'zdb_aborted_xids')
);
$$;
CREATE OR REPLACE FUNCTION zdb.vac_by_xmax(index regclass, type text, xmax bigint) RETURNS zdbquery PARALLEL SAFE STABLE STRICT LANGUAGE sql AS $$
/*
* docs with committed xmax
*/
SELECT dsl.and(
dsl.range(field=>'zdb_xmax', lt=>xmax),
dsl.noteq(dsl.terms_lookup('zdb_xmax', zdb.index_name(index), type, 'zdb_aborted_xids', 'zdb_aborted_xids'))
);
$$;
CREATE OR REPLACE FUNCTION zdb.vac_aborted_xmax(index regclass, type text, xmax bigint) RETURNS zdbquery PARALLEL SAFE STABLE STRICT LANGUAGE sql AS $$
/*
* docs with aborted xmax
*/
SELECT dsl.and(
dsl.range(field=>'zdb_xmax', lt=>xmax),
dsl.terms_lookup('zdb_xmax', zdb.index_name(index), type, 'zdb_aborted_xids', 'zdb_aborted_xids')
);
$$;
CREATE OR REPLACE FUNCTION zdb.internal_visibility_clause(index regclass) RETURNS zdbquery PARALLEL SAFE STABLE STRICT LANGUAGE c AS 'MODULE_PATHNAME', 'zdb_internal_visibility_clause';
|
<reponame>yudong2015/openpitrix<gh_stars>100-1000
ALTER TABLE repo
ADD COLUMN owner_path VARCHAR(255) NOT NULL;
CREATE INDEX repo_owner_path_idx
ON repo (owner_path);
UPDATE repo
SET owner_path = CONCAT(':', owner);
ALTER TABLE repo_event
ADD COLUMN owner_path VARCHAR(255) NOT NULL;
CREATE INDEX repo_event_owner_path_idx
ON repo_event (owner_path);
UPDATE repo_event
SET owner_path = CONCAT(':', owner);
|
CREATE TEMPORARY FUNCTION
getDir(x STRING)
RETURNS STRING
LANGUAGE js AS """
function getDir(s) {
try {
return URI(s).directory();
} catch (ex) {
return s;
}
}
return getDir(x);
"""
OPTIONS
( library="gs://commonspeak-udf/URI.min.js" );
SELECT
getDir(url) AS url,
COUNT(url) AS count
FROM
`httparchive.requests.{{date}}_desktop`
GROUP BY
url
ORDER BY
count DESC
LIMIT {{limit}}; |
<filename>dbscript/B_CONTINGENT_ENTRY_Insert_Update.sql
/****** Object: StoredProcedure [dbo].[B_CONTINGENT_ENTRY_Insert_Update] Script Date: 13/11/2014 2:20:48 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--select convert(date,'9/12/2014')
ALTER PROCEDURE [dbo].[B_CONTINGENT_ENTRY_Insert_Update](@CollateralInfoID nvarchar(20), @ContingentEntryID nvarchar(20), @CustomerID nvarchar(20), @CustomerAddress nvarchar(250),
@DocIDTaxCode nvarchar(50), @DateOfIssue nvarchar(50), @TransactionCode nvarchar(10),
@TransactionName nvarchar(200), @DCMode nvarchar(20), @DCName nvarchar(100), @Currency nvarchar(20), @AccountNo nvarchar(20), @AccountName nvarchar(300),
@Amount decimal(18,2), @DealRate decimal(10,6), @ValueDate date, @Narrative nvarchar(300), @ApprovedUser nvarchar(200), @CollateralTypeCode nvarchar(20))
AS
IF @DateOfIssue !='' set @DateOfIssue = convert(date,@DateOfIssue) else set @DateOfIssue =null;
IF exists (select [ContingentEntryID] FROM [dbo].[BCOLLATERALCONTINGENT_ENTRY] WHERE [ContingentEntryID]= @ContingentEntryID)
BEGIN
UPDATE [dbo].[BCOLLATERALCONTINGENT_ENTRY] SET [CollateralInfoID]=@CollateralInfoID,[ContingentEntryID]=@ContingentEntryID,[CustomerID]=@CustomerID
,[CustomerAddress]=@CustomerAddress,[DocIDTaxCode]=@DocIDTaxCode,[DateOfIssue]=@DateOfIssue,[TransactionCode]=@TransactionCode,[TransactionName]=@TransactionName
,[DCTypeCode]=@DCMode,[DCTypeName]=@DCName,[Currency]=@Currency, [AccountNo]= @AccountNo,[AccountName]=@AccountName,[Amount]=@Amount,[DealRate]=@DealRate
,[ValueDate]=@ValueDate,[Narrative]=@Narrative,[ApprovedUser]=@ApprovedUser, [CollateralType_Code] = @CollateralTypeCode
WHERE [ContingentEntryID]= @ContingentEntryID
END
ELSE
BEGIN
INSERT INTO [dbo].[BCOLLATERALCONTINGENT_ENTRY]([CollateralInfoID],[ContingentEntryID],[CustomerID],[CustomerAddress],[DocIDTaxCode],[DateOfIssue],[TransactionCode]
,[TransactionName],[DCTypeCode],[DCTypeName],[Currency],[AccountNo],[AccountName],[Amount],[DealRate],[ValueDate],[Narrative],[ApprovedUser],[CollateralType_Code])
VALUES(@CollateralInfoID, @ContingentEntryID, @CustomerID, @CustomerAddress, @DocIDTaxCode, @DateOfIssue, @TransactionCode, @TransactionName, @DCMode, @DCName
, @Currency, @AccountNo, @AccountName,@Amount, @DealRate, @ValueDate,@Narrative, @ApprovedUser,@CollateralTypeCode)
END
GO
|
<filename>gsm/db/functions/create.function.getNeighborBrightestInCat.sql<gh_stars>0
--DROP FUNCTION getNeighborBrightestInCat;
/*
CREATE FUNCTION testReturnTable(catname VARCHAR(50)
,ira DOUBLE
,idecl DOUBLE)
RETURNS TABLE (ocatsrcid INT
,ozoneheight DOUBLE
)
BEGIN
RETURN TABLE
(SELECT 1
,2
)
;
END;
*/
CREATE FUNCTION getNeighborBrightestInCat(icatname VARCHAR(50)
,itheta DOUBLE
,ira DOUBLE
,idecl DOUBLE
) RETURNS TABLE (catsrcid INT
,ra DOUBLE
,decl DOUBLE
,freq_eff DOUBLE
,i_int_avg DOUBLE
,i_int_avg_err DOUBLE
,dist_arcsec DOUBLE
)
BEGIN
DECLARE izoneheight DOUBLE;
/*SELECT zoneheight
INTO izoneheight
FROM zoneheight
;
*/
SET izoneheight = 1.0;
RETURN TABLE
(
SELECT catsrcid
,ra
,decl
,c1.freq_eff
,c1.i_int_avg
,c1.i_int_avg_err
,3600 * DEGREES(2 * ASIN(SQRT( (c1.x - COS(RADIANS(idecl)) * COS(RADIANS(ira)))
* (c1.x - COS(RADIANS(idecl)) * COS(RADIANS(ira)))
+ (c1.y - COS(RADIANS(idecl)) * SIN(RADIANS(ira)))
* (c1.y - COS(RADIANS(idecl)) * SIN(RADIANS(ira)))
+ (c1.z - SIN(RADIANS(idecl)))
* (c1.z - SIN(RADIANS(idecl)))
)
/ 2
)
) as dist_arcsec
FROM catalogedsources c1
,catalogs c0
WHERE c1.cat_id = c0.catid
AND c0.catname = UPPER(icatname)
AND c1.x * COS(RADIANS(idecl)) * COS(RADIANS(ira))
+ c1.y * COS(RADIANS(idecl)) * SIN(RADIANS(ira))
+ c1.z * SIN(RADIANS(idecl)) > COS(RADIANS(itheta))
AND c1.zone BETWEEN CAST(FLOOR((idecl - itheta) / izoneheight) AS INTEGER)
AND CAST(FLOOR((idecl + itheta) / izoneheight) AS INTEGER)
AND c1.ra BETWEEN ira - alpha(itheta, idecl)
AND ira + alpha(itheta, idecl)
AND c1.decl BETWEEN idecl - itheta
AND idecl + itheta
AND c1.i_int_avg = (SELECT MAX(c1.i_int_avg)
FROM catalogedsources c1
,catalogs c0
WHERE c1.cat_id = c0.catid
AND c0.catname = icatname
AND c1.x * COS(RADIANS(idecl)) * COS(RADIANS(ira))
+ c1.y * COS(RADIANS(idecl)) * SIN(RADIANS(ira))
+ c1.z * SIN(RADIANS(idecl)) > COS(RADIANS(itheta))
AND c1.zone BETWEEN CAST(FLOOR((idecl - itheta) / izoneheight) AS INTEGER)
AND CAST(FLOOR((idecl + itheta) / izoneheight) AS INTEGER)
AND c1.ra BETWEEN ira - alpha(itheta, idecl)
AND ira + alpha(itheta, idecl)
AND c1.decl BETWEEN idecl - itheta
AND idecl + itheta
)
)
;
END;
|
<filename>kopi (3).sql
-- phpMyAdmin SQL Dump
-- version 4.7.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 05, 2019 at 08:17 AM
-- Server version: 10.1.26-MariaDB
-- PHP Version: 7.1.9
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `kopi`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE `admin` (
`id_admin` int(11) NOT NULL,
`password_admin` varchar(225) DEFAULT NULL,
`username_admin` varchar(225) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `admin`
--
INSERT INTO `admin` (`id_admin`, `password_admin`, `username_admin`) VALUES
(1, '1', 'admin');
-- --------------------------------------------------------
--
-- Table structure for table `foto`
--
CREATE TABLE `foto` (
`id_foto` int(11) NOT NULL,
`path_foto` varchar(225) NOT NULL,
`kopi_id_kopi` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `foto`
--
INSERT INTO `foto` (`id_foto`, `path_foto`, `kopi_id_kopi`) VALUES
(1, 'assets/img/coffee/1ff00286-90fd-44e0-b398-06e14f360e9c.jpg', 3),
(2, 'assets/img/coffee/db9b5054-59ac-46ed-bc1b-c49574be8035.jpg', 3),
(3, 'assets/img/coffee/3041ebf4-51ea-4da9-a022-b4d5d053d1fe.jpg', 4),
(4, 'assets/img/coffee/f18b1390-6ac9-46e1-bede-80241b8e2f6e.jpg', 5),
(5, 'assets/img/coffee/f6b84f2d-911c-409f-b92e-50655a7e5265.jpg', 6),
(6, 'assets/img/coffee/c421ce2a-8f70-42a5-a5d5-1b282c90caf9.jpg', 7),
(7, 'assets/img/coffee/7eee151b-f728-460f-9ad8-0bf7d85acaef.jpg', 9),
(8, 'assets/img/coffee/cddc43c7-3576-489d-a1ff-6cb57abc249d.jpg', 10),
(9, 'assets/img/coffee/000d6fb9-c61e-496c-92eb-15185d6fc82a.jpg', 11),
(10, 'assets/img/coffee/d1591551-4478-4726-baf3-bca8aed90317.jpg', 12),
(11, 'assets/img/coffee/d8d54995-b85a-434a-99c1-3d0f41b19ecf.jpg', 13),
(12, 'assets/img/coffee/aa9c691f-df72-4d9f-8e0f-240dcdc38286.jpg', 13),
(13, 'assets/img/coffee/76f74929-49b8-4a92-abb1-45ddc18d7e67.jpg', 13),
(14, 'assets/img/coffee/0e6a5860-ec94-4745-b28d-38e67b7d1cb3.jpg', 14);
-- --------------------------------------------------------
--
-- Table structure for table `jenis_kopi`
--
CREATE TABLE `jenis_kopi` (
`id_jenis_kopi` int(2) NOT NULL,
`jenis_kopi` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `jenis_kopi`
--
INSERT INTO `jenis_kopi` (`id_jenis_kopi`, `jenis_kopi`) VALUES
(1, 'Arabica'),
(2, 'Robusta'),
(3, 'Blend');
-- --------------------------------------------------------
--
-- Table structure for table `komentar`
--
CREATE TABLE `komentar` (
`id_komentar` int(11) NOT NULL,
`member_id_member` int(11) DEFAULT NULL,
`roaster_id_roaster` int(11) DEFAULT NULL,
`kopi_id_kopi` int(11) NOT NULL,
`waktu_komentar` datetime DEFAULT NULL,
`isi_komentar` varchar(500) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `komentar`
--
INSERT INTO `komentar` (`id_komentar`, `member_id_member`, `roaster_id_roaster`, `kopi_id_kopi`, `waktu_komentar`, `isi_komentar`) VALUES
(1, 1, 3, 14, '2019-07-03 00:00:00', 'ini isi komentar');
-- --------------------------------------------------------
--
-- Table structure for table `kopi`
--
CREATE TABLE `kopi` (
`id_kopi` int(11) NOT NULL,
`nama_kopi` varchar(225) DEFAULT NULL,
`acidity` int(11) DEFAULT NULL,
`sweet` int(11) DEFAULT NULL,
`bitter` int(11) DEFAULT NULL,
`savory` int(11) DEFAULT NULL,
`origin` varchar(225) DEFAULT NULL,
`deskripsi_kopi` varchar(225) DEFAULT NULL,
`roaster_id_roaster` int(11) NOT NULL,
`roast_prof_id_roast_prof` int(11) NOT NULL,
`jenis_kopi_id_jenis_kopi` int(2) NOT NULL,
`proses_kopi_id_proses_kopi` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `kopi`
--
INSERT INTO `kopi` (`id_kopi`, `nama_kopi`, `acidity`, `sweet`, `bitter`, `savory`, `origin`, `deskripsi_kopi`, `roaster_id_roaster`, `roast_prof_id_roast_prof`, `jenis_kopi_id_jenis_kopi`, `proses_kopi_id_proses_kopi`) VALUES
(3, 'adasdsad', 2, 3, 4, 5, 'asdasda', 'https://goo.gl/maps/uwnFPe4egm2b7r2C6', 1, 1, 1, 1),
(4, 'kasjdasjdlsakdjlaksdj', 5, 1, 1, 1, 'Papua', 'adadasd', 1, 2, 3, 2),
(5, 'asdada', 4, 4, 4, 4, 'Papua', 'adadasd', 1, 2, 3, 2),
(6, 'asdfqwffqfqf', 4, 4, 4, 4, 'Papua', 'adadasd', 1, 2, 3, 2),
(7, 'asdfqwffqfqfas', 4, 4, 4, 4, 'Papua', 'adadasd', 1, 2, 3, 2),
(9, 'Kopi roaster 2', 2, 2, 2, 2, 'origin', 'alksdjasldk', 1, 4, 2, 3),
(10, 'Kopi roaster 2', 2, 2, 2, 2, 'origin', 'alksdjasldk', 1, 4, 2, 3),
(11, 'Kopi roaster 2', 2, 2, 2, 2, 'origin', 'alksdjasldk', 1, 4, 2, 3),
(12, 'sdsdfds', 4, 4, 4, 4, 'sdfsdf', 'asdassad', 1, 4, 2, 2),
(13, '<NAME>', 6, 8, 5, 6, 'Aceh', 'This coffee was our attempt in doing non-conventional coffee processing: anaerobic cherry maceration. If not carefully done, this kind of process can be a disaster resulting in coffee that has over-fermented flavor, something', 3, 3, 1, 1),
(14, '<NAME>', 3, 5, 7, 4, 'Bali', 'Our coffee from West Java, Halu Pink Banana, has been everybody\'s favorite and in 2018 was one of our best selling coffee. We are working meticulously with the processor that has been working together with us for 3 years now.', 3, 4, 1, 4);
-- --------------------------------------------------------
--
-- Table structure for table `kopi_has_tastes`
--
CREATE TABLE `kopi_has_tastes` (
`kopi_id_kopi` int(11) NOT NULL,
`tastes_id_tastes` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `kopi_has_tastes`
--
INSERT INTO `kopi_has_tastes` (`kopi_id_kopi`, `tastes_id_tastes`) VALUES
(12, 2),
(3, 41),
(3, 27),
(3, 41),
(3, 20),
(13, 13),
(14, 39);
-- --------------------------------------------------------
--
-- Table structure for table `member`
--
CREATE TABLE `member` (
`id_member` int(11) NOT NULL,
`nama_member` varchar(225) DEFAULT NULL,
`email_member` varchar(20) DEFAULT NULL,
`username_member` varchar(225) DEFAULT NULL,
`password_member` varchar(225) DEFAULT NULL,
`foto_member` varchar(225) DEFAULT NULL,
`keterangan_member` varchar(225) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `member`
--
INSERT INTO `member` (`id_member`, `nama_member`, `email_member`, `username_member`, `password_member`, `foto_member`, `keterangan_member`) VALUES
(1, 'Saya member pertama', '<EMAIL>', 'member1', '1', NULL, 'asdasdasdads'),
(2, 'asdsad', '<EMAIL>', 'member2', '1', NULL, 'asdasdasdasdasd'),
(3, 'member ketiga', '<EMAIL>', 'member3', '1', NULL, 'ini adalah member ketiga saya');
-- --------------------------------------------------------
--
-- Table structure for table `proses_kopi`
--
CREATE TABLE `proses_kopi` (
`id_proses_kopi` int(11) NOT NULL,
`nama_proses` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `proses_kopi`
--
INSERT INTO `proses_kopi` (`id_proses_kopi`, `nama_proses`) VALUES
(1, 'Natural'),
(2, 'Washed'),
(3, 'Semi Washed'),
(4, 'Honey/Mield'),
(5, 'Natural Pulp');
-- --------------------------------------------------------
--
-- Table structure for table `roaster`
--
CREATE TABLE `roaster` (
`id_roaster` int(11) NOT NULL,
`nama_roaster` varchar(225) DEFAULT NULL,
`username_roaster` varchar(225) DEFAULT NULL,
`password_roaster` varchar(225) DEFAULT NULL,
`deskripsi_roaster` tinytext,
`alamat_roaster` tinytext,
`lokasi` varchar(225) DEFAULT NULL,
`telp_roaster` varchar(45) DEFAULT NULL,
`foto_roaster` varchar(225) DEFAULT NULL,
`email_roaster` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `roaster`
--
INSERT INTO `roaster` (`id_roaster`, `nama_roaster`, `username_roaster`, `password_ro<PASSWORD>`, `deskripsi_roaster`, `alamat_roaster`, `lokasi`, `telp_roaster`, `foto_roaster`, `email_roaster`) VALUES
(1, 'Roaster Pertama', 'roaster1', '1', 'ini adlaha roaster pertama', '1', NULL, '1', NULL, '<EMAIL>'),
(3, 'Space Roastery', 'space', '1', 'Rasakan kopi paling fresh dan berkualitas langsung dari tempat pengolahannya\r\n Roast to Order\r\n· IBC Jury Tested ·\r\n 100% Handmade · \r\nFree Delivery Nationwide', 'Gang Loncang 88, Jalan Magelang KM 4.5 (depan TVRI), Rogoyudan, Sinduadi, Kec. Mlati, Kota Yogyakarta, Daerah Istimewa Yogyakarta 55284', 'https://goo.gl/maps/ERn2ywm36WKCAET49', '0822-8890-9088', 'space_profile.png', '<EMAIL>');
-- --------------------------------------------------------
--
-- Table structure for table `roast_prof`
--
CREATE TABLE `roast_prof` (
`id_roast_prof` int(11) NOT NULL,
`nama_roast_prof` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `roast_prof`
--
INSERT INTO `roast_prof` (`id_roast_prof`, `nama_roast_prof`) VALUES
(1, 'Light'),
(2, 'Light to Medium'),
(3, 'Medium'),
(4, 'Medium to Dark'),
(5, 'Dark');
-- --------------------------------------------------------
--
-- Table structure for table `tastes`
--
CREATE TABLE `tastes` (
`id_tastes` int(11) NOT NULL,
`nama_tastes` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tastes`
--
INSERT INTO `tastes` (`id_tastes`, `nama_tastes`) VALUES
(1, 'Fruity'),
(2, 'Blackberry'),
(3, 'Raspberry'),
(4, 'Blueberry'),
(5, 'Strawberry'),
(6, 'Raisin'),
(7, 'Prune'),
(8, 'Coconut'),
(9, 'Cherry'),
(10, 'Pomegrante'),
(11, 'Pineapple'),
(12, 'Grape'),
(13, 'Apple'),
(14, 'Peach'),
(15, 'Pear'),
(16, 'Grapefruit'),
(17, 'Orange'),
(18, 'Lemon'),
(19, 'Lime'),
(20, 'Citric Acid'),
(21, 'Malic Acid'),
(22, 'Winey'),
(23, 'Floral'),
(24, 'Chamomile'),
(25, 'Rose'),
(26, 'Jasmine'),
(27, 'Black Tea'),
(28, 'Sweet'),
(29, 'Vanilin'),
(30, 'Vanilin'),
(31, 'Vanila'),
(32, 'Raisin'),
(33, 'Brownsugar'),
(34, 'Honey'),
(35, 'Caramelized'),
(36, 'Mapple Syrup'),
(37, 'Molasses'),
(38, 'Nutty/Cocoa'),
(39, 'Dark Chocolate'),
(40, 'Chocolate'),
(41, 'Almond'),
(42, 'Hazlenut'),
(43, 'Peanuts'),
(44, 'Spices');
-- --------------------------------------------------------
--
-- Table structure for table `view`
--
CREATE TABLE `view` (
`member_id_member` int(11) NOT NULL,
`kopi_id_kopi` int(11) NOT NULL,
`waktu_view` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `view`
--
INSERT INTO `view` (`member_id_member`, `kopi_id_kopi`, `waktu_view`) VALUES
(1, 3, '2019-06-29 03:33:01'),
(1, 3, '2019-06-29 03:33:39'),
(1, 3, '2019-06-29 03:33:55'),
(1, 3, '2019-06-29 03:34:21'),
(1, 3, '2019-06-29 03:35:34'),
(1, 3, '2019-06-29 03:43:19'),
(1, 3, '2019-06-29 03:44:45'),
(1, 3, '2019-06-29 03:44:48'),
(1, 14, '2019-07-02 19:21:21'),
(1, 14, '2019-07-02 19:25:57'),
(1, 14, '2019-07-02 19:26:31'),
(1, 14, '2019-07-02 19:27:22'),
(1, 14, '2019-07-02 19:27:28'),
(1, 14, '2019-07-02 19:28:10'),
(1, 14, '2019-07-02 19:29:08'),
(1, 14, '2019-07-02 19:29:26'),
(1, 14, '2019-07-02 19:30:05'),
(1, 14, '2019-07-02 19:31:56'),
(1, 14, '2019-07-02 19:32:28'),
(1, 14, '2019-07-02 19:33:17'),
(1, 14, '2019-07-02 19:33:58'),
(1, 14, '2019-07-02 19:34:18'),
(1, 14, '2019-07-02 19:34:59'),
(1, 14, '2019-07-02 19:35:35'),
(1, 14, '2019-07-02 19:37:02'),
(1, 14, '2019-07-02 19:38:36'),
(1, 14, '2019-07-02 19:39:25'),
(1, 14, '2019-07-02 19:40:18'),
(1, 14, '2019-07-02 19:40:54'),
(1, 14, '2019-07-02 19:41:40'),
(1, 14, '2019-07-02 19:41:48'),
(1, 14, '2019-07-02 19:42:02'),
(1, 14, '2019-07-02 19:42:21'),
(1, 14, '2019-07-02 19:43:46'),
(1, 14, '2019-07-02 20:11:29'),
(1, 14, '2019-07-02 20:15:20'),
(1, 14, '2019-07-02 20:18:29'),
(1, 14, '2019-07-02 20:22:08'),
(1, 14, '2019-07-02 20:23:58'),
(1, 14, '2019-07-02 20:34:41'),
(1, 14, '2019-07-02 20:35:42');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admin`
--
ALTER TABLE `admin`
ADD PRIMARY KEY (`id_admin`);
--
-- Indexes for table `foto`
--
ALTER TABLE `foto`
ADD PRIMARY KEY (`id_foto`),
ADD KEY `fk_foto_kopi1_idx` (`kopi_id_kopi`);
--
-- Indexes for table `jenis_kopi`
--
ALTER TABLE `jenis_kopi`
ADD PRIMARY KEY (`id_jenis_kopi`);
--
-- Indexes for table `komentar`
--
ALTER TABLE `komentar`
ADD PRIMARY KEY (`id_komentar`),
ADD KEY `fk_member_has_kopi_kopi1_idx` (`kopi_id_kopi`),
ADD KEY `fk_member_has_kopi_member1_idx` (`member_id_member`),
ADD KEY `fk_interaksi_roaster1_idx` (`roaster_id_roaster`);
--
-- Indexes for table `kopi`
--
ALTER TABLE `kopi`
ADD PRIMARY KEY (`id_kopi`),
ADD KEY `fk_kopi_roaster_idx` (`roaster_id_roaster`),
ADD KEY `fk_kopi_roast_prof1_idx` (`roast_prof_id_roast_prof`),
ADD KEY `fk_kopi_jenis_kopi1_idx` (`jenis_kopi_id_jenis_kopi`),
ADD KEY `fk_kopi_proses_kopi1_idx` (`proses_kopi_id_proses_kopi`);
--
-- Indexes for table `kopi_has_tastes`
--
ALTER TABLE `kopi_has_tastes`
ADD KEY `fk_kopi_has_tastes_tastes1_idx` (`tastes_id_tastes`),
ADD KEY `fk_kopi_has_tastes_kopi1_idx` (`kopi_id_kopi`);
--
-- Indexes for table `member`
--
ALTER TABLE `member`
ADD PRIMARY KEY (`id_member`);
--
-- Indexes for table `proses_kopi`
--
ALTER TABLE `proses_kopi`
ADD PRIMARY KEY (`id_proses_kopi`);
--
-- Indexes for table `roaster`
--
ALTER TABLE `roaster`
ADD PRIMARY KEY (`id_roaster`);
--
-- Indexes for table `roast_prof`
--
ALTER TABLE `roast_prof`
ADD PRIMARY KEY (`id_roast_prof`);
--
-- Indexes for table `tastes`
--
ALTER TABLE `tastes`
ADD PRIMARY KEY (`id_tastes`);
--
-- Indexes for table `view`
--
ALTER TABLE `view`
ADD KEY `fk_member_has_kopi_kopi2_idx` (`kopi_id_kopi`),
ADD KEY `fk_member_has_kopi_member2_idx` (`member_id_member`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `admin`
--
ALTER TABLE `admin`
MODIFY `id_admin` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `foto`
--
ALTER TABLE `foto`
MODIFY `id_foto` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
--
-- AUTO_INCREMENT for table `jenis_kopi`
--
ALTER TABLE `jenis_kopi`
MODIFY `id_jenis_kopi` int(2) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `komentar`
--
ALTER TABLE `komentar`
MODIFY `id_komentar` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `kopi`
--
ALTER TABLE `kopi`
MODIFY `id_kopi` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
--
-- AUTO_INCREMENT for table `member`
--
ALTER TABLE `member`
MODIFY `id_member` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `proses_kopi`
--
ALTER TABLE `proses_kopi`
MODIFY `id_proses_kopi` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `roaster`
--
ALTER TABLE `roaster`
MODIFY `id_roaster` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `roast_prof`
--
ALTER TABLE `roast_prof`
MODIFY `id_roast_prof` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `tastes`
--
ALTER TABLE `tastes`
MODIFY `id_tastes` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=45;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `foto`
--
ALTER TABLE `foto`
ADD CONSTRAINT `fk_foto_kopi1` FOREIGN KEY (`kopi_id_kopi`) REFERENCES `kopi` (`id_kopi`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `komentar`
--
ALTER TABLE `komentar`
ADD CONSTRAINT `fk_interaksi_roaster1` FOREIGN KEY (`roaster_id_roaster`) REFERENCES `roaster` (`id_roaster`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_member_has_kopi_kopi1` FOREIGN KEY (`kopi_id_kopi`) REFERENCES `kopi` (`id_kopi`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_member_has_kopi_member1` FOREIGN KEY (`member_id_member`) REFERENCES `member` (`id_member`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `kopi`
--
ALTER TABLE `kopi`
ADD CONSTRAINT `fk_kopi_jenis_kopi1` FOREIGN KEY (`jenis_kopi_id_jenis_kopi`) REFERENCES `jenis_kopi` (`id_jenis_kopi`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_kopi_proses_kopi1` FOREIGN KEY (`proses_kopi_id_proses_kopi`) REFERENCES `proses_kopi` (`id_proses_kopi`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_kopi_roast_prof1` FOREIGN KEY (`roast_prof_id_roast_prof`) REFERENCES `roast_prof` (`id_roast_prof`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_kopi_roaster` FOREIGN KEY (`roaster_id_roaster`) REFERENCES `roaster` (`id_roaster`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `kopi_has_tastes`
--
ALTER TABLE `kopi_has_tastes`
ADD CONSTRAINT `fk_kopi_has_tastes_kopi1` FOREIGN KEY (`kopi_id_kopi`) REFERENCES `kopi` (`id_kopi`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_kopi_has_tastes_tastes1` FOREIGN KEY (`tastes_id_tastes`) REFERENCES `tastes` (`id_tastes`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `view`
--
ALTER TABLE `view`
ADD CONSTRAINT `fk_member_has_kopi_kopi2` FOREIGN KEY (`kopi_id_kopi`) REFERENCES `kopi` (`id_kopi`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_member_has_kopi_member2` FOREIGN KEY (`member_id_member`) REFERENCES `member` (`id_member`) ON DELETE NO ACTION ON UPDATE NO ACTION;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
<filename>storage/uploads/file_abcd (3).sql
-- phpMyAdmin SQL Dump
-- version 4.1.12
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Feb 03, 2016 at 01:11 PM
-- Server version: 5.6.16
-- PHP Version: 5.5.11
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `ppdu`
--
-- --------------------------------------------------------
--
-- Table structure for table `AgendaAttachments`
--
DROP TABLE IF EXISTS `AgendaAttachments`;
CREATE TABLE IF NOT EXISTS `AgendaAttachments` (
`AgendaAttachmentID` int(11) NOT NULL AUTO_INCREMENT,
`AgendaID` int(11) NOT NULL,
`AttachmentDescription` varchar(255) NOT NULL,
`DocumentID` int(11) NOT NULL,
PRIMARY KEY (`AgendaAttachmentID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `AgendaItems`
--
DROP TABLE IF EXISTS `AgendaItems`;
CREATE TABLE IF NOT EXISTS `AgendaItems` (
`AgendaItemId` int(11) NOT NULL AUTO_INCREMENT,
`MeetingID` int(11) NOT NULL,
`Title` varchar(255) NOT NULL,
`RaisedBy` varchar(50) NOT NULL,
PRIMARY KEY (`AgendaItemId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `Agendas`
--
DROP TABLE IF EXISTS `Agendas`;
CREATE TABLE IF NOT EXISTS `Agendas` (
`AgendaID` int(11) NOT NULL AUTO_INCREMENT,
`ProposedMeetingDate` date NOT NULL,
`MeetingID` int(11) NOT NULL,
`MinistryID` int(11) NOT NULL,
`DocumentID` int(11) NOT NULL,
PRIMARY KEY (`AgendaID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `Agendas`
--
INSERT INTO `Agendas` (`AgendaID`, `ProposedMeetingDate`, `MeetingID`, `MinistryID`, `DocumentID`) VALUES
(1, '2016-01-12', 1, 2, 2),
(2, '2016-01-06', 2, 1, 3);
-- --------------------------------------------------------
--
-- Table structure for table `AllowedUsers`
--
DROP TABLE IF EXISTS `AllowedUsers`;
CREATE TABLE IF NOT EXISTS `AllowedUsers` (
`WorkflowStateID` int(11) NOT NULL,
`UserID` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `ApprovalDecisionLetters`
--
DROP TABLE IF EXISTS `ApprovalDecisionLetters`;
CREATE TABLE IF NOT EXISTS `ApprovalDecisionLetters` (
`ApprovalDecisionLetterID` int(11) NOT NULL AUTO_INCREMENT,
`MemoID` int(11) NOT NULL,
`MinistryID` int(11) NOT NULL,
`DecisionStatusID` int(11) NOT NULL,
`DocumentID` int(11) NOT NULL,
PRIMARY KEY (`ApprovalDecisionLetterID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `ApprovalDecisionLetters`
--
INSERT INTO `ApprovalDecisionLetters` (`ApprovalDecisionLetterID`, `MemoID`, `MinistryID`, `DecisionStatusID`, `DocumentID`) VALUES
(1, 1, 2, 1, 4);
-- --------------------------------------------------------
--
-- Table structure for table `ApprovalMemos`
--
DROP TABLE IF EXISTS `ApprovalMemos`;
CREATE TABLE IF NOT EXISTS `ApprovalMemos` (
`ApprovalMemoID` int(11) NOT NULL AUTO_INCREMENT,
`MeetingID` int(11) NOT NULL,
`MinistryID` int(11) NOT NULL,
`DocumentID` int(11) NOT NULL,
PRIMARY KEY (`ApprovalMemoID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `ApprovalMemos`
--
INSERT INTO `ApprovalMemos` (`ApprovalMemoID`, `MeetingID`, `MinistryID`, `DocumentID`) VALUES
(1, 1, 2, 1);
-- --------------------------------------------------------
--
-- Table structure for table `CommitteeReports`
--
DROP TABLE IF EXISTS `CommitteeReports`;
CREATE TABLE IF NOT EXISTS `CommitteeReports` (
`CommitteeReportID` int(11) NOT NULL AUTO_INCREMENT,
`MemoID` int(11) NOT NULL,
`MeetingID` int(11) NOT NULL,
`MinistryID` int(11) NOT NULL,
`RecommendationStatusID` int(11) NOT NULL,
`DocumentID` int(11) NOT NULL,
PRIMARY KEY (`CommitteeReportID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `CommitteeReports`
--
INSERT INTO `CommitteeReports` (`CommitteeReportID`, `MemoID`, `MeetingID`, `MinistryID`, `RecommendationStatusID`, `DocumentID`) VALUES
(1, 2, 1, 2, 1, 3);
-- --------------------------------------------------------
--
-- Table structure for table `Contractors`
--
DROP TABLE IF EXISTS `Contractors`;
CREATE TABLE IF NOT EXISTS `Contractors` (
`ContractorID` int(11) NOT NULL AUTO_INCREMENT,
`Contractor` varchar(30) NOT NULL,
PRIMARY KEY (`ContractorID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `DecisionLetters`
--
DROP TABLE IF EXISTS `DecisionLetters`;
CREATE TABLE IF NOT EXISTS `DecisionLetters` (
`DecisionLetterID` int(11) NOT NULL AUTO_INCREMENT,
`MemoID` int(11) NOT NULL,
`MeetingID` int(11) NOT NULL,
`MinistryID` int(11) NOT NULL,
`DecisionStatusID` int(11) NOT NULL,
`DocumentID` int(11) NOT NULL,
PRIMARY KEY (`DecisionLetterID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `DecisionLetters`
--
INSERT INTO `DecisionLetters` (`DecisionLetterID`, `MemoID`, `MeetingID`, `MinistryID`, `DecisionStatusID`, `DocumentID`) VALUES
(1, 2, 1, 2, 1, 4);
-- --------------------------------------------------------
--
-- Table structure for table `DecisionStatus`
--
DROP TABLE IF EXISTS `DecisionStatus`;
CREATE TABLE IF NOT EXISTS `DecisionStatus` (
`DecisionStatusID` int(11) NOT NULL AUTO_INCREMENT,
`DecisionStatus` varchar(30) NOT NULL,
PRIMARY KEY (`DecisionStatusID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Dumping data for table `DecisionStatus`
--
INSERT INTO `DecisionStatus` (`DecisionStatusID`, `DecisionStatus`) VALUES
(1, 'Approved'),
(2, 'Stood Down'),
(3, 'Referred to Committee');
-- --------------------------------------------------------
--
-- Table structure for table `Districts`
--
DROP TABLE IF EXISTS `Districts`;
CREATE TABLE IF NOT EXISTS `Districts` (
`DistrictID` int(11) NOT NULL AUTO_INCREMENT,
`District` varchar(30) NOT NULL,
PRIMARY KEY (`DistrictID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `Documents`
--
DROP TABLE IF EXISTS `Documents`;
CREATE TABLE IF NOT EXISTS `Documents` (
`DocumentID` int(11) NOT NULL AUTO_INCREMENT,
`DocumentTitle` varchar(255) NOT NULL,
`ReferenceNo` varchar(255) NOT NULL,
`DocumentDate` date NOT NULL,
`Keywords` varchar(400) NOT NULL,
`FilePath` varchar(255) NOT NULL,
`DocumentTypeID` int(11) NOT NULL,
`UploadDate` date NOT NULL,
PRIMARY KEY (`DocumentID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
--
-- Dumping data for table `Documents`
--
INSERT INTO `Documents` (`DocumentID`, `DocumentTitle`, `ReferenceNo`, `DocumentDate`, `Keywords`, `FilePath`, `DocumentTypeID`, `UploadDate`) VALUES
(1, 'Memo: The status of the electrical power distribution network', 'MEn/123/ME/16/01/1', '2016-01-02', 'power, distribution network, electricity', 'theFileName.pdf', 1, '2016-01-04'),
(2, 'Meeting Minutes', 'ref1105', '2016-12-01', '', '/Applications/XAMPP/xamppfiles/temp/phpypiWvx', 0, '0000-00-00'),
(3, 'Meeting Minutes', 'ref1157', '1212-12-12', '', '/Applications/XAMPP/xamppfiles/temp/phpOn6f4K', 0, '0000-00-00'),
(4, 'Meeting Minutes', '44', '2012-11-20', '', '/Applications/XAMPP/xamppfiles/temp/phpiL6qxy', 0, '0000-00-00'),
(5, 'Meeting Minutes', '44', '2012-09-03', '', '/Applications/XAMPP/xamppfiles/temp/phpuwLevo', 0, '0000-00-00'),
(6, 'Meeting Minutes', '44', '2012-09-07', '', '/Applications/XAMPP/xamppfiles/temp/phpbQptHP', 0, '0000-00-00'),
(7, 'Meeting Minutes', '44', '2012-09-08', '', '/Applications/XAMPP/xamppfiles/temp/phpdO0mHl', 0, '0000-00-00'),
(8, 'Meeting Minutes', '44', '2012-09-08', '', '/Applications/XAMPP/xamppfiles/temp/php0gfJWC', 0, '0000-00-00');
-- --------------------------------------------------------
--
-- Table structure for table `DocumentStateHistory`
--
DROP TABLE IF EXISTS `DocumentStateHistory`;
CREATE TABLE IF NOT EXISTS `DocumentStateHistory` (
`DocumentStateHistoryID` int(11) NOT NULL AUTO_INCREMENT,
`DocumentID` int(11) NOT NULL,
`WorkflowStateID` int(11) NOT NULL,
`CreatedDate` date NOT NULL,
`SenderID` int(11) NOT NULL,
`RecipientID` int(11) NOT NULL,
`Comments` varchar(500) NOT NULL,
PRIMARY KEY (`DocumentStateHistoryID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `DocumentTypes`
--
DROP TABLE IF EXISTS `DocumentTypes`;
CREATE TABLE IF NOT EXISTS `DocumentTypes` (
`DocumentTypeID` int(11) NOT NULL AUTO_INCREMENT,
`DocumentType` varchar(30) NOT NULL,
`TableName` varchar(30) NOT NULL,
PRIMARY KEY (`DocumentTypeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `DocumentTypes`
--
INSERT INTO `DocumentTypes` (`DocumentTypeID`, `DocumentType`, `TableName`) VALUES
(1, 'Memo', 'memos'),
(2, 'Forwarding Letter', 'forwardingletters');
-- --------------------------------------------------------
--
-- Table structure for table `ForwardingLetters`
--
DROP TABLE IF EXISTS `ForwardingLetters`;
CREATE TABLE IF NOT EXISTS `ForwardingLetters` (
`ForwardingLetterID` int(11) NOT NULL AUTO_INCREMENT,
`MemoID` int(11) NOT NULL,
`MinistryID` int(11) NOT NULL,
`DocumentID` int(11) NOT NULL,
PRIMARY KEY (`ForwardingLetterID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `ForwardingLetters`
--
INSERT INTO `ForwardingLetters` (`ForwardingLetterID`, `MemoID`, `MinistryID`, `DocumentID`) VALUES
(1, 1, 2, 4),
(2, 1, 1, 3);
-- --------------------------------------------------------
--
-- Table structure for table `FundingSources`
--
DROP TABLE IF EXISTS `FundingSources`;
CREATE TABLE IF NOT EXISTS `FundingSources` (
`FundingSourceID` int(11) NOT NULL AUTO_INCREMENT,
`FundingSource` varchar(30) NOT NULL,
PRIMARY KEY (`FundingSourceID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `MeetingParticipants`
--
DROP TABLE IF EXISTS `MeetingParticipants`;
CREATE TABLE IF NOT EXISTS `MeetingParticipants` (
`MeetingParticipantsID` int(11) NOT NULL AUTO_INCREMENT,
`MeetingID` int(11) NOT NULL,
`UserID` int(11) NOT NULL,
PRIMARY KEY (`MeetingParticipantsID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `Meetings`
--
DROP TABLE IF EXISTS `Meetings`;
CREATE TABLE IF NOT EXISTS `Meetings` (
`MeetingID` int(11) NOT NULL AUTO_INCREMENT,
`MeetingNumber` varchar(50) NOT NULL,
`ProposedMeetingDate` date NOT NULL,
`WasPostponed` tinyint(4) NOT NULL DEFAULT '0',
`DocumentID` int(11) NOT NULL,
PRIMARY KEY (`MeetingID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Dumping data for table `Meetings`
--
INSERT INTO `Meetings` (`MeetingID`, `MeetingNumber`, `ProposedMeetingDate`, `WasPostponed`, `DocumentID`) VALUES
(1, 'mtgNo123', '2016-01-01', 0, 1),
(2, 'meeting No 4', '2016-01-12', 0, 4),
(3, 'meeting No 5', '2016-01-12', 0, 4);
-- --------------------------------------------------------
--
-- Table structure for table `MeetingTypes`
--
DROP TABLE IF EXISTS `MeetingTypes`;
CREATE TABLE IF NOT EXISTS `MeetingTypes` (
`MeetingTypeID` int(11) NOT NULL AUTO_INCREMENT,
`MeetingType` varchar(30) NOT NULL,
PRIMARY KEY (`MeetingTypeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `MeetingTypes`
--
INSERT INTO `MeetingTypes` (`MeetingTypeID`, `MeetingType`) VALUES
(1, 'Special'),
(2, 'Normal');
-- --------------------------------------------------------
--
-- Table structure for table `Memos`
--
DROP TABLE IF EXISTS `Memos`;
CREATE TABLE IF NOT EXISTS `Memos` (
`MemoID` int(11) NOT NULL AUTO_INCREMENT,
`MinistryID` int(11) NOT NULL,
`IsSigned` tinyint(4) NOT NULL,
`HasTitle` tinyint(11) NOT NULL,
`HasSummary` tinyint(11) NOT NULL,
`PriorityID` int(11) NOT NULL,
`SourceID` int(11) NOT NULL,
`MemoContent` varchar(2000) NOT NULL,
`DocumentID` int(11) NOT NULL,
PRIMARY KEY (`MemoID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `Memos`
--
INSERT INTO `Memos` (`MemoID`, `MinistryID`, `IsSigned`, `HasTitle`, `HasSummary`, `PriorityID`, `SourceID`, `MemoContent`, `DocumentID`) VALUES
(1, 1, 1, 1, 1, 1, 1, 'memo conente', 1),
(2, 2, 1, 1, 1, 1, 1, 'some memo content', 2);
-- --------------------------------------------------------
--
-- Table structure for table `Ministries`
--
DROP TABLE IF EXISTS `Ministries`;
CREATE TABLE IF NOT EXISTS `Ministries` (
`MinistryID` int(11) NOT NULL AUTO_INCREMENT,
`Ministry` varchar(30) NOT NULL,
PRIMARY KEY (`MinistryID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `Ministries`
--
INSERT INTO `Ministries` (`MinistryID`, `Ministry`) VALUES
(1, 'Mines and Energy'),
(2, 'Ministry of Health');
-- --------------------------------------------------------
--
-- Table structure for table `Minutes`
--
DROP TABLE IF EXISTS `Minutes`;
CREATE TABLE IF NOT EXISTS `Minutes` (
`MinutesID` int(11) NOT NULL AUTO_INCREMENT,
`MeetingID` int(11) NOT NULL,
`ActualMeetingDate` date NOT NULL,
`MeetingTypeID` int(11) NOT NULL,
`DocumentID` int(11) NOT NULL,
PRIMARY KEY (`MinutesID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;
--
-- Dumping data for table `Minutes`
--
INSERT INTO `Minutes` (`MinutesID`, `MeetingID`, `ActualMeetingDate`, `MeetingTypeID`, `DocumentID`) VALUES
(1, 1, '2016-01-12', 1, 1),
(2, 1, '1212-12-11', 1, 0),
(3, 1, '1212-12-11', 1, 0),
(4, 1, '2020-11-12', 1, 2),
(6, 1, '1212-11-30', 1, 2),
(7, 1, '1212-11-30', 1, 2),
(8, 1, '0000-00-00', 1, 2),
(9, 1, '2016-12-01', 1, 2),
(10, 1, '1212-12-12', 1, 2),
(11, 1, '2012-09-08', 1, 2);
-- --------------------------------------------------------
--
-- Table structure for table `Priorities`
--
DROP TABLE IF EXISTS `Priorities`;
CREATE TABLE IF NOT EXISTS `Priorities` (
`PriorityID` int(11) NOT NULL AUTO_INCREMENT,
`PriorityName` varchar(50) NOT NULL,
PRIMARY KEY (`PriorityID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `ProjectReports`
--
DROP TABLE IF EXISTS `ProjectReports`;
CREATE TABLE IF NOT EXISTS `ProjectReports` (
`ProjectReportID` int(11) NOT NULL AUTO_INCREMENT,
`ProjectID` int(11) NOT NULL,
`DocumentID` int(11) NOT NULL,
PRIMARY KEY (`ProjectReportID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `Projects`
--
DROP TABLE IF EXISTS `Projects`;
CREATE TABLE IF NOT EXISTS `Projects` (
`ProjectID` int(11) NOT NULL AUTO_INCREMENT,
`ProjectName` varchar(255) NOT NULL,
`RegionID` int(11) NOT NULL,
`DistrictID` int(11) NOT NULL,
`Locality` varchar(100) NOT NULL,
`ContractorID` int(11) NOT NULL,
`ContractAmount` decimal(14,2) NOT NULL,
`PercentageDone` int(11) NOT NULL,
`ExpectedPercentage` int(11) NOT NULL,
`FundingSourceID` int(11) NOT NULL,
`StatusID` int(11) NOT NULL,
`MDAID` int(11) NOT NULL,
`ProjectCreationDate` date NOT NULL,
`SourceID` int(11) NOT NULL,
`PriorityID` int(11) NOT NULL,
`DecisionMemoDate` int(11) NOT NULL,
`MinistryContact` int(11) NOT NULL,
`ProjectTypeID` int(11) NOT NULL,
`Verification` int(11) NOT NULL,
`DocumentID` int(11) NOT NULL COMMENT 'Perhaps memo approving project',
PRIMARY KEY (`ProjectID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `ProjectStatus`
--
DROP TABLE IF EXISTS `ProjectStatus`;
CREATE TABLE IF NOT EXISTS `ProjectStatus` (
`ProjectStatusID` int(11) NOT NULL AUTO_INCREMENT,
`ProjectStatus` varchar(30) NOT NULL,
PRIMARY KEY (`ProjectStatusID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `ProjectTypes`
--
DROP TABLE IF EXISTS `ProjectTypes`;
CREATE TABLE IF NOT EXISTS `ProjectTypes` (
`ProjectTypeID` int(11) NOT NULL AUTO_INCREMENT,
`ProjectType` varchar(30) NOT NULL,
PRIMARY KEY (`ProjectTypeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `RecommendationStatus`
--
DROP TABLE IF EXISTS `RecommendationStatus`;
CREATE TABLE IF NOT EXISTS `RecommendationStatus` (
`RecommendationStatusID` int(11) NOT NULL AUTO_INCREMENT,
`RecommendationStatus` varchar(30) NOT NULL,
PRIMARY KEY (`RecommendationStatusID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `Regions`
--
DROP TABLE IF EXISTS `Regions`;
CREATE TABLE IF NOT EXISTS `Regions` (
`RegionID` int(11) NOT NULL AUTO_INCREMENT,
`Region` varchar(30) NOT NULL,
PRIMARY KEY (`RegionID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `Sources`
--
DROP TABLE IF EXISTS `Sources`;
CREATE TABLE IF NOT EXISTS `Sources` (
`SourceID` int(11) NOT NULL AUTO_INCREMENT,
`Source` varchar(30) NOT NULL,
PRIMARY KEY (`SourceID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dumping data for table `Sources`
--
INSERT INTO `Sources` (`SourceID`, `Source`) VALUES
(1, 'SONA'),
(2, 'Dev'),
(3, 'PDU'),
(4, 'ToC');
-- --------------------------------------------------------
--
-- Table structure for table `UserLevels`
--
DROP TABLE IF EXISTS `UserLevels`;
CREATE TABLE IF NOT EXISTS `UserLevels` (
`UserLevelID` int(11) NOT NULL AUTO_INCREMENT,
`UserLevel` varchar(30) NOT NULL,
PRIMARY KEY (`UserLevelID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `Users`
--
DROP TABLE IF EXISTS `Users`;
CREATE TABLE IF NOT EXISTS `Users` (
`UserID` int(11) NOT NULL AUTO_INCREMENT,
`Username` varchar(50) NOT NULL,
`Password` varchar(120) NOT NULL,
`UserLevelID` int(11) NOT NULL,
`Email` varchar(50) NOT NULL,
`PhoneNo` varchar(14) NOT NULL,
`CreatedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`UpdatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`UserID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `WorkflowNavigation`
--
DROP TABLE IF EXISTS `WorkflowNavigation`;
CREATE TABLE IF NOT EXISTS `WorkflowNavigation` (
`WorkflowNavigationID` int(11) NOT NULL AUTO_INCREMENT,
`WorkflowStateID` int(11) NOT NULL,
`NextWorkflowStateID` int(11) NOT NULL,
PRIMARY KEY (`WorkflowNavigationID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `Workflows`
--
DROP TABLE IF EXISTS `Workflows`;
CREATE TABLE IF NOT EXISTS `Workflows` (
`WorkflowID` int(11) NOT NULL AUTO_INCREMENT,
`WorkflowName` varchar(50) NOT NULL,
PRIMARY KEY (`WorkflowID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `WorkflowStates`
--
DROP TABLE IF EXISTS `WorkflowStates`;
CREATE TABLE IF NOT EXISTS `WorkflowStates` (
`WorkflowStateID` int(11) NOT NULL AUTO_INCREMENT,
`StateName` varchar(50) NOT NULL,
`WorkflowID` int(11) NOT NULL,
`IsActive` tinyint(4) NOT NULL,
PRIMARY KEY (`WorkflowStateID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `xDecisions`
--
DROP TABLE IF EXISTS `xDecisions`;
CREATE TABLE IF NOT EXISTS `xDecisions` (
`DecisionID` int(11) NOT NULL AUTO_INCREMENT,
`DecisionDate` date NOT NULL,
`MeetingID` int(11) NOT NULL,
`MeetingNumber` varchar(50) NOT NULL,
`MeetingDate` date NOT NULL,
`Content` varchar(2000) NOT NULL,
`MinistryID` int(11) NOT NULL,
`DecisionStatusID` int(11) NOT NULL,
`DocumentID` int(11) NOT NULL,
PRIMARY KEY (`DecisionID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `xExecutiveApprovalMemo`
--
DROP TABLE IF EXISTS `xExecutiveApprovalMemo`;
CREATE TABLE IF NOT EXISTS `xExecutiveApprovalMemo` (
`ExecutiveApprovalMemoID` int(11) NOT NULL AUTO_INCREMENT,
`MinistryID` int(11) NOT NULL,
`DocumentID` int(11) NOT NULL,
PRIMARY KEY (`ExecutiveApprovalMemoID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
Select * from InformacoesCondutor;
Select * from InformacoesCorrida;
Select * from InformacoesVeiculo;
-- CHECK PLACA = 7 caracteres
insert into Veiculo
values ("012345671238", "abc0f", 123);
-- INSERT Data final menor que data inicial
select * from Motorista;
insert into Motorista (data_inicio, data_fim,renavan,CPF_condutor)
values ("2019-10-11 12:30:01", "2019-10-11 12:30:01", "012345681", "12345678901");
-- INSERT AVALICAO FORA DE 0 - 5
SELECT * FROM Corrida;
insert into Corrida (id_corrida,avaliacao_condutor
,avaliacao_veiculo
,data_inicio
,data_fim
,origem
,destino
,tarifa
,distancia
,id_motorista
,CPF_passageiro)
values (13,6,null,"2019-10-11 12:30:01", null , "sapiranga", "sapiranga", 0.3, 0.5, 4, "01234567893");
--
insert into Corrida (id_corrida,avaliacao_condutor
,avaliacao_veiculo
,data_inicio
,data_fim
,origem
,destino
,tarifa
,distancia
,id_motorista
,CPF_passageiro)
values (13,-3,null,"2019-10-11 12:30:01", null , "sapiranga", "sapiranga", 0.3, 0.5, 4, "01234567893");
-- TRIGGER Evita Mesmo veiculo em uso por dois motoristas
select * from Motorista;
insert into Motorista (data_inicio, data_fim,renavan,CPF_condutor)
values (now(), now(), "012345682", "12345678901");
-- TRIGGER EvitaCondutorRetirar2Veiculos
select * from Motorista;
insert into Motorista (data_inicio, data_fim,renavan,CPF_condutor)
values (now(), now(), "012345678", "12345678906");
-- TRIGGER EvitaPassageito2ViagensAoMesmoTempo
SELECT * FROM Corrida;
insert into Corrida (id_corrida,avaliacao_condutor
,avaliacao_veiculo
,data_inicio
,data_fim
,origem
,destino
,tarifa
,distancia
,id_motorista
,CPF_passageiro)
values (13,null,null,"2019-10-11 12:30:01", null , "sapiranga", "sapiranga", 0.3, 0.5, 4, "01234567891");
-- TRIGGER EvitaCondutor2ViagensAoMesmoTempo
SELECT * FROM Corrida;
insert into Corrida (id_corrida,avaliacao_condutor
,avaliacao_veiculo
,data_inicio
,data_fim
,origem
,destino
,tarifa
,distancia
,id_motorista
,CPF_passageiro)
values (13,null,null,"2019-10-11 12:30:01", null , "sapiranga", "sapiranga", 0.3, 0.5, 1, "01234567894");
|
CREATE TABLE "blocks" (
"height" INTEGER NOT NULL UNIQUE,
"hash" CHAR(64) PRIMARY KEY NOT NULL,
"time" TIMESTAMP
); |
<reponame>manniwood/mpjw
{ #{setUpperString} = call upper( #{getLowerString} ) } |
<filename>Database Basics/MSSQL Server Exam - 22 October 2017/MSSQL Server Exam - 22 October 2017/13. Numbers Coincidence.sql
SELECT DISTINCT u.Username
FROM users as u
JOIN Reports AS r
ON r.UserId = u.Id
WHERE LEFT(u.Username, 1) LIKE '[0-9]' AND CONVERT(NVARCHAR(10), r.CategoryId) = LEFT(u.Username, 1) OR
RIGHT(u.Username, 1) LIKE '[0-9]' AND CONVERT(NVARCHAR(10), r.CategoryId) = RIGHT(u.Username, 1)
ORDER BY u.Username
|
create database motor
use motor
create table motor (
id int IDENTITY(1,1) PRIMARY KEY,
mesin varchar(100) NOT NULL,
brand varchar(100),
name varchar(100),
types varchar(100),
manufacture date NULL,
color varchar(100),
jumlah int
)
select *from motor
drop table motor
create table ambil (
id int IDENTITY(1,1) PRIMARY KEY,
id_motor int,
jumlah_motor int,
taking date null
)
select * from ambil
drop table ambil
create trigger insert_data_ambil
on ambil after insert
as
update motor set motor.jumlah = motor.jumlah-inserted.jumlah_motor
from inserted where motor.id = inserted.id_motor
create table bahan (
id int IDENTITY(1,1) PRIMARY KEY,
bahan varchar(30),
nomor_bahan varchar(30),
types varchar(30),
jumlah int,
manufacture date NULL,
expired date NULL
)
create table creates (
id int IDENTITY(1,1) PRIMARY KEY,
id_bahan int,
jumlah_create int,
taking date NULL
)
create trigger insert_data_creates
on creates after insert
as
update bahan set bahan.jumlah = bahan.jumlah-inserted.jumlah_create
from inserted where bahan.id = inserted.id_bahan
|
<reponame>rzdzaky/tokokitashop
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Mar 25, 2021 at 09:44 AM
-- Server version: 10.4.14-MariaDB
-- PHP Version: 7.4.9
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `admin12`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_admin`
--
CREATE TABLE `tbl_admin` (
`idAdmin` int(2) NOT NULL,
`userName` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `tbl_admin`
--
INSERT INTO `tbl_admin` (`idAdmin`, `userName`, `password`) VALUES
(1, 'admin', '<PASSWORD>');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_biaya_kirim`
--
CREATE TABLE `tbl_biaya_kirim` (
`idBiayaKirim` int(5) NOT NULL,
`idKurir` int(3) NOT NULL,
`idKotaAsal` int(4) NOT NULL,
`idKotaTujuan` int(4) NOT NULL,
`biaya` int(5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_detail_order`
--
CREATE TABLE `tbl_detail_order` (
`idDetailOrder` int(10) NOT NULL,
`idOrder` int(5) NOT NULL,
`idProduk` int(5) NOT NULL,
`jumlah` int(5) NOT NULL,
`harga` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_kategori`
--
CREATE TABLE `tbl_kategori` (
`idkat` int(5) NOT NULL,
`namakat` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_konfirmasi`
--
CREATE TABLE `tbl_konfirmasi` (
`idKonfirmasi` int(5) NOT NULL,
`idOrder` int(5) NOT NULL,
`buktiTransfer` varchar(100) NOT NULL,
`validasi` enum('Y','N') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_kota`
--
CREATE TABLE `tbl_kota` (
`idKota` int(4) NOT NULL,
`namaKota` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_kurir`
--
CREATE TABLE `tbl_kurir` (
`idKurir` int(2) NOT NULL,
`namaKurir` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_member`
--
CREATE TABLE `tbl_member` (
`idKonsumen` int(5) NOT NULL,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
`namaKonsumen` varchar(50) NOT NULL,
`alamat` varchar(200) NOT NULL,
`idKota` int(4) NOT NULL,
`email` varchar(100) NOT NULL,
`tlpn` int(20) NOT NULL,
`statusAktif` enum('Y','N') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_order`
--
CREATE TABLE `tbl_order` (
`idOrder` int(5) NOT NULL,
`idKonsumen` int(5) NOT NULL,
`tglOrder` date NOT NULL,
`statusOrder` enum('Belum Bayar','Dikemas','Dikirim','Diterima','Selesai','Dibatalkan') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_produk`
--
CREATE TABLE `tbl_produk` (
`idProduk` int(5) NOT NULL,
`idKat` int(5) NOT NULL,
`idToko` int(5) NOT NULL,
`namaProduk` varchar(50) NOT NULL,
`foto` varchar(100) NOT NULL,
`harga` int(10) NOT NULL,
`stok` int(5) NOT NULL,
`berat` int(5) NOT NULL,
`deskripsiProduk` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_saldo`
--
CREATE TABLE `tbl_saldo` (
`idSaldo` int(5) NOT NULL,
`idToko` int(5) NOT NULL,
`jumlah` int(10) NOT NULL,
`tanggal` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_toko`
--
CREATE TABLE `tbl_toko` (
`idToko` int(5) NOT NULL,
`idKonsumen` int(5) NOT NULL,
`namaToko` varchar(100) NOT NULL,
`logo` varchar(100) NOT NULL,
`deskripsi` text NOT NULL,
`statusAktif` enum('Y','N') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `tbl_admin`
--
ALTER TABLE `tbl_admin`
ADD PRIMARY KEY (`idAdmin`);
--
-- Indexes for table `tbl_biaya_kirim`
--
ALTER TABLE `tbl_biaya_kirim`
ADD PRIMARY KEY (`idBiayaKirim`),
ADD KEY `idKurir` (`idKurir`),
ADD KEY `idKotaAsal` (`idKotaAsal`),
ADD KEY `idKotaTujuan` (`idKotaTujuan`);
--
-- Indexes for table `tbl_detail_order`
--
ALTER TABLE `tbl_detail_order`
ADD PRIMARY KEY (`idDetailOrder`),
ADD UNIQUE KEY `jumlah` (`jumlah`),
ADD KEY `jumlah_2` (`jumlah`),
ADD KEY `jumlah_3` (`jumlah`),
ADD KEY `idProduk` (`idProduk`),
ADD KEY `idOrder` (`idOrder`),
ADD KEY `harga` (`harga`);
--
-- Indexes for table `tbl_kategori`
--
ALTER TABLE `tbl_kategori`
ADD PRIMARY KEY (`idkat`);
--
-- Indexes for table `tbl_konfirmasi`
--
ALTER TABLE `tbl_konfirmasi`
ADD PRIMARY KEY (`idKonfirmasi`),
ADD KEY `idOrder` (`idOrder`);
--
-- Indexes for table `tbl_kota`
--
ALTER TABLE `tbl_kota`
ADD PRIMARY KEY (`idKota`);
--
-- Indexes for table `tbl_kurir`
--
ALTER TABLE `tbl_kurir`
ADD PRIMARY KEY (`idKurir`);
--
-- Indexes for table `tbl_member`
--
ALTER TABLE `tbl_member`
ADD PRIMARY KEY (`idKonsumen`),
ADD UNIQUE KEY `idKota` (`idKota`),
ADD KEY `idKota_2` (`idKota`),
ADD KEY `idKota_3` (`idKota`);
--
-- Indexes for table `tbl_order`
--
ALTER TABLE `tbl_order`
ADD PRIMARY KEY (`idOrder`),
ADD KEY `idKonsumen` (`idKonsumen`);
--
-- Indexes for table `tbl_produk`
--
ALTER TABLE `tbl_produk`
ADD PRIMARY KEY (`idProduk`),
ADD UNIQUE KEY `idToko` (`idToko`),
ADD KEY `idToko_2` (`idToko`),
ADD KEY `idToko_3` (`idToko`),
ADD KEY `tbl_produk_ibfk_2` (`idKat`);
--
-- Indexes for table `tbl_saldo`
--
ALTER TABLE `tbl_saldo`
ADD PRIMARY KEY (`idSaldo`),
ADD KEY `idToko` (`idToko`),
ADD KEY `idToko_2` (`idToko`);
--
-- Indexes for table `tbl_toko`
--
ALTER TABLE `tbl_toko`
ADD PRIMARY KEY (`idToko`),
ADD KEY `idKonsumen` (`idKonsumen`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `tbl_kategori`
--
ALTER TABLE `tbl_kategori`
MODIFY `idkat` int(5) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `tbl_biaya_kirim`
--
ALTER TABLE `tbl_biaya_kirim`
ADD CONSTRAINT `tbl_biaya_kirim_ibfk_1` FOREIGN KEY (`idKotaAsal`) REFERENCES `tbl_kota` (`idKota`) ON DELETE NO ACTION ON UPDATE CASCADE,
ADD CONSTRAINT `tbl_biaya_kirim_ibfk_2` FOREIGN KEY (`idKotaTujuan`) REFERENCES `tbl_kota` (`idKota`) ON DELETE NO ACTION ON UPDATE CASCADE,
ADD CONSTRAINT `tbl_biaya_kirim_ibfk_3` FOREIGN KEY (`idKurir`) REFERENCES `tbl_kurir` (`idKurir`) ON DELETE NO ACTION ON UPDATE CASCADE;
--
-- Constraints for table `tbl_detail_order`
--
ALTER TABLE `tbl_detail_order`
ADD CONSTRAINT `tbl_detail_order_ibfk_1` FOREIGN KEY (`idProduk`) REFERENCES `tbl_produk` (`idProduk`) ON DELETE NO ACTION ON UPDATE CASCADE,
ADD CONSTRAINT `tbl_detail_order_ibfk_2` FOREIGN KEY (`idOrder`) REFERENCES `tbl_order` (`idOrder`) ON DELETE NO ACTION ON UPDATE CASCADE;
--
-- Constraints for table `tbl_konfirmasi`
--
ALTER TABLE `tbl_konfirmasi`
ADD CONSTRAINT `tbl_konfirmasi_ibfk_1` FOREIGN KEY (`idOrder`) REFERENCES `tbl_order` (`idOrder`) ON DELETE NO ACTION ON UPDATE CASCADE;
--
-- Constraints for table `tbl_member`
--
ALTER TABLE `tbl_member`
ADD CONSTRAINT `tbl_member_ibfk_1` FOREIGN KEY (`idKota`) REFERENCES `tbl_kota` (`idKota`) ON DELETE NO ACTION ON UPDATE CASCADE;
--
-- Constraints for table `tbl_order`
--
ALTER TABLE `tbl_order`
ADD CONSTRAINT `tbl_order_ibfk_1` FOREIGN KEY (`idKonsumen`) REFERENCES `tbl_member` (`idKonsumen`) ON DELETE NO ACTION ON UPDATE CASCADE;
--
-- Constraints for table `tbl_produk`
--
ALTER TABLE `tbl_produk`
ADD CONSTRAINT `tbl_produk_ibfk_1` FOREIGN KEY (`idToko`) REFERENCES `tbl_toko` (`idToko`) ON DELETE NO ACTION ON UPDATE CASCADE;
--
-- Constraints for table `tbl_saldo`
--
ALTER TABLE `tbl_saldo`
ADD CONSTRAINT `tbl_saldo_ibfk_1` FOREIGN KEY (`idToko`) REFERENCES `tbl_toko` (`idToko`) ON DELETE NO ACTION ON UPDATE CASCADE;
--
-- Constraints for table `tbl_toko`
--
ALTER TABLE `tbl_toko`
ADD CONSTRAINT `tbl_toko_ibfk_2` FOREIGN KEY (`idKonsumen`) REFERENCES `tbl_member` (`idKonsumen`) ON DELETE NO ACTION ON UPDATE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
<filename>dist/sql/npcs.sql
CREATE TABLE IF NOT EXISTS `npcs` (
`npc_id` int(4) DEFAULT '0',
`type` enum('NPC','MONSTER') DEFAULT 'NPC' NOT NULL,
`level` int(4) DEFAULT '1',
`sex` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
`hp` int(8) DEFAULT '100',
`stamina` int(4) DEFAULT '0',
`strength` int(4) DEFAULT '0',
`dexterity` int(4) DEFAULT '0',
`intelect` int(4) DEFAULT '0'
) CHARSET=latin1 COLLATE=latin1_general_ci;
INSERT INTO `npcs` VALUES ('1', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('2', 'NPC', '1', '1', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('3', 'MONSTER', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('4', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('5', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('6', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('7', 'NPC', '1', '1', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('8', 'NPC', '1', '1', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('9', 'NPC', '1', '1', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('10', 'NPC', '1', '1', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('11', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('12', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('13', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('14', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('15', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('16', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('17', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('18', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('19', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('20', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('21', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('22', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('23', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('24', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('25', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('26', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('27', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('28', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('29', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('30', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('31', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('32', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('33', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('34', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('35', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('36', 'NPC', '1', '0', '100', '0', '0', '0', '0');
INSERT INTO `npcs` VALUES ('37', 'NPC', '1', '0', '100', '0', '0', '0', '0');
|
<filename>status/private/migrations/app/1593087212_add_mute_chat_and_raw_message_fields.up.sql
ALTER TABLE chats ADD COLUMN muted BOOLEAN DEFAULT FALSE;
ALTER TABLE raw_messages ADD COLUMN skip_encryption BOOLEAN DEFAULT FALSE;
ALTER TABLE raw_messages ADD COLUMN send_push_notification BOOLEAN DEFAULT FALSE;
|
<filename>src/Import/WideWorldImportersFromScript/Application/Tables/People.sql
CREATE TABLE [Application].[People](
[PersonID] [int] NOT NULL,
[FullName] [nvarchar](50) COLLATE Latin1_General_100_CI_AS NOT NULL,
[PreferredName] [nvarchar](50) COLLATE Latin1_General_100_CI_AS NOT NULL,
[SearchName] AS (concat([PreferredName],N' ',[FullName])) PERSISTED NOT NULL,
[IsPermittedToLogon] [bit] NOT NULL,
[LogonName] [nvarchar](50) COLLATE Latin1_General_100_CI_AS NULL,
[IsExternalLogonProvider] [bit] NOT NULL,
[HashedPassword] [varbinary](max) NULL,
[IsSystemUser] [bit] NOT NULL,
[IsEmployee] [bit] NOT NULL,
[IsSalesperson] [bit] NOT NULL,
[UserPreferences] [nvarchar](max) COLLATE Latin1_General_100_CI_AS NULL,
[PhoneNumber] [nvarchar](20) COLLATE Latin1_General_100_CI_AS NULL,
[FaxNumber] [nvarchar](20) COLLATE Latin1_General_100_CI_AS NULL,
[EmailAddress] [nvarchar](256) COLLATE Latin1_General_100_CI_AS NULL,
[Photo] [varbinary](max) NULL,
[CustomFields] [nvarchar](max) COLLATE Latin1_General_100_CI_AS NULL,
[OtherLanguages] AS (json_query([CustomFields],N'$.OtherLanguages')),
[LastEditedBy] [int] NOT NULL,
[ValidFrom] [datetime2](7) GENERATED ALWAYS AS ROW START NOT NULL,
[ValidTo] [datetime2](7) GENERATED ALWAYS AS ROW END NOT NULL,
CONSTRAINT [PK_Application_People] PRIMARY KEY CLUSTERED
(
[PersonID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [USERDATA],
PERIOD FOR SYSTEM_TIME ([ValidFrom], [ValidTo])
) ON [USERDATA] TEXTIMAGE_ON [USERDATA]
WITH
(
SYSTEM_VERSIONING = ON ( HISTORY_TABLE = [Application].[People_Archive] )
)
GO
ALTER TABLE [Application].[People] WITH CHECK ADD CONSTRAINT [FK_Application_People_Application_People] FOREIGN KEY([LastEditedBy])
REFERENCES [Application].[People] ([PersonID])
GO
ALTER TABLE [Application].[People] CHECK CONSTRAINT [FK_Application_People_Application_People]
GO
ALTER TABLE [Application].[People] ADD CONSTRAINT [DF_Application_People_PersonID] DEFAULT (NEXT VALUE FOR [Sequences].[PersonID]) FOR [PersonID]
GO
/****** Object: Index [IX_Application_People_FullName] Script Date: 10/06/2020 18:14:17 ******/
CREATE NONCLUSTERED INDEX [IX_Application_People_FullName] ON [Application].[People]
(
[FullName] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [USERDATA]
GO
/****** Object: Index [IX_Application_People_IsEmployee] Script Date: 10/06/2020 18:14:17 ******/
CREATE NONCLUSTERED INDEX [IX_Application_People_IsEmployee] ON [Application].[People]
(
[IsEmployee] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [USERDATA]
GO
/****** Object: Index [IX_Application_People_IsSalesperson] Script Date: 10/06/2020 18:14:17 ******/
CREATE NONCLUSTERED INDEX [IX_Application_People_IsSalesperson] ON [Application].[People]
(
[IsSalesperson] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [USERDATA]
GO
/****** Object: Index [IX_Application_People_Perf_20160301_05] Script Date: 10/06/2020 18:14:17 ******/
CREATE NONCLUSTERED INDEX [IX_Application_People_Perf_20160301_05] ON [Application].[People]
(
[IsPermittedToLogon] ASC,
[PersonID] ASC
)
INCLUDE([FullName],[EmailAddress]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [USERDATA]
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Numeric ID used for reference to a person within the database' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'PersonID'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Full name for this person' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'FullName'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Name that this person prefers to be called' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'PreferredName'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Name to build full text search on (computed column)' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'SearchName'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Is this person permitted to log on?' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'IsPermittedToLogon'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Person''s system logon name' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'LogonName'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Is logon token provided by an external system?' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'IsExternalLogonProvider'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Hash of password for users without external logon tokens' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'HashedPassword'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Is the currently permitted to make online access?' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'IsSystemUser'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Is this person an employee?' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'IsEmployee'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Is this person a staff salesperson?' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'IsSalesperson'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'User preferences related to the website (holds JSON data)' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'UserPreferences'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Phone number' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'PhoneNumber'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Fax number ' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'FaxNumber'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Email address for this person' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'EmailAddress'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Photo of this person' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'Photo'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Custom fields for employees and salespeople' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'CustomFields'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Other languages spoken (computed column from custom fields)' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'OtherLanguages'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Improves performance of name-related queries' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'INDEX',@level2name=N'IX_Application_People_FullName'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Allows quickly locating employees' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'INDEX',@level2name=N'IX_Application_People_IsEmployee'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Allows quickly locating salespeople' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'INDEX',@level2name=N'IX_Application_People_IsSalesperson'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Improves performance of order picking and invoicing' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People', @level2type=N'INDEX',@level2name=N'IX_Application_People_Perf_20160301_05'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'People known to the application (staff, customer contacts, supplier contacts)' , @level0type=N'SCHEMA',@level0name=N'Application', @level1type=N'TABLE',@level1name=N'People' |
<reponame>Shuttl-Tech/antlr_psql<gh_stars>10-100
-- file:rangefuncs.sql ln:559 expect:true
alter table users add column junk text
|
ALTER SYSTEM SET NLS_DATE_LANGUAGE='DEU';
ALTER SYSTEM SET NLS_FIRST_DAY_OF_WEEK=1;
|
DROP DATABASE IF EXISTS sample_db;
CREATE DATABASE sample_db DEFAULT CHARACTER SET utf8;
USE sample_db;
CREATE TABLE t_user (
user_id BIGINT NOT NULL AUTO_INCREMENT COMMENT 'user id',
user_name VARCHAR(30) NOT NULL COMMENT 'user name',
reg_date datetime COMMENT 'register date',
reg_ip VARCHAR(23) COMMENT 'register ip',
PRIMARY KEY (user_id)
)ENGINE=InnoDB;
CREATE TABLE t_fund (
user_id BIGINT NOT NULL COMMENT 'user_id in table t_user',
currency_type INT NOT NULL COMMENT 'currency type',
amount BIGINT NOT NULL COMMENT 'cash amount'
)ENGINE=InnoDB;
CREATE UNIQUE INDEX INDEX_user_currency ON t_fund (user_id, currency_type);
INSERT INTO t_user (user_name, reg_date, reg_ip) values
("testuser1", now(), "127.0.0.1"),
("testuser2", now(), "127.0.0.1"),
("testuser3", now(), "127.0.0.1"),
("testuser4", now(), "127.0.0.1"),
("testuser5", now(), "127.0.0.1"),
("testuser6", now(), "127.0.0.1"),
("testuser7", now(), "127.0.0.1"),
("testuser8", now(), "127.0.0.1"),
("testuser9", now(), "127.0.0.1"),
("testuser10", now(), "127.0.0.1");
INSERT INTO t_fund (user_id, currency_type, amount) values
(1, 0, 1000000),
(1, 1, 1000000),
(2, 0, 1000000),
(2, 1, 1000000),
(3, 0, 1000000),
(3, 1, 1000000),
(4, 0, 1000000),
(4, 1, 1000000),
(5, 0, 1000000),
(5, 1, 1000000),
(6, 0, 1000000),
(6, 1, 1000000),
(7, 0, 1000000),
(7, 1, 1000000),
(8, 0, 1000000),
(8, 1, 1000000),
(9, 0, 1000000),
(9, 1, 1000000),
(10, 0, 1000000),
(10, 1, 1000000); |
CREATE TABLE linksmenutop (
id CHAVE NOT NULL,
id_shop CHAVE NOT NULL,
new_window BOOLEAN NOT NULL,
CONSTRAINT pk_linksmenutop PRIMARY KEY (id)
); |
with countries AS (
SELECT
country
FROM
suppliers
UNION
SELECT
country
FROM
customers
), suppliercountry AS (
SELECT
distinct country
FROM
suppliers
), customercountry AS (
SELECT
distinct country
FROM
customers
)
SELECT
sp.country as suplier_country,
cp.country as customer_country
FROM
countries c
LEFT JOIN
suppliercountry sp on c.country = sp.country
LEFT JOIN
customercountry cp on c.country = cp.country
|
CREATE TABLE data (
contact_id integer CONSTRAINT firstkey PRIMARY KEY NOT NULL,
lastname varchar(50),
firstname varchar(100),
address varchar(300),
phonenumber varchar(50),
email varchar(100),
addinform varchar(500),
dt varchar(50),
d varchar(20),
url_photo varchar(100),
img varchar(80)
); |
<filename>conf/evolutions/default/1.sql
# --- !Ups
CREATE TABLE "user" (
id uuid primary key default uuid_generate_v4(),
name VARCHAR,
email VARCHAR,
password VARCHAR,
avatar_url VARCHAR,
"desc" VARCHAR
);
CREATE TABLE "gallery" (
id uuid primary key default uuid_generate_v4(),
name VARCHAR,
"desc" VARCHAR,
img_small_url VARCHAR,
img_large_url VARCHAR
);
CREATE TABLE "email_news" (
id uuid primary key default uuid_generate_v4(),
email VARCHAR,
"data" timestamp with time zone
);
CREATE TABLE "contact" (
id uuid primary key default uuid_generate_v4(),
name VARCHAR,
email VARCHAR,
web_site VARCHAR,
text_email VARCHAR,
"data" timestamp with time zone,
"sent" boolean
);
CREATE TABLE "category" (
id uuid primary key default uuid_generate_v4(),
name VARCHAR,
"url" VARCHAR,
"desc" VARCHAR
);
CREATE TABLE "product" (
id uuid primary key default uuid_generate_v4(),
category_id uuid,
name VARCHAR,
"desc" VARCHAR,
img_small_url VARCHAR,
img_large_url VARCHAR,
comments VARCHAR,
feature boolean,
FOREIGN KEY (category_id) REFERENCES category(id)
);
# --- !Downs
DROP TABLE IF EXISTS user;
DROP TABLE IF EXISTS gallery;
DROP TABLE IF EXISTS email_news;
DROP TABLE IF EXISTS contact;
DROP TABLE IF EXISTS category;
DROP TABLE IF EXISTS product; |
-- Verify ggircs-portal:mutations/create_product_naics_code on pg
begin;
select pg_get_functiondef('ggircs_portal.create_product_naics_code(int, int, boolean)'::regprocedure);
rollback;
|
-- Custom script to create a function to check if any errors occurred for JobExecution.
-- Changes in this file will not result in an update of the function.
-- To change the function, update this script and copy it to the appropriate scripts.snippet field of the schema.json
CREATE OR REPLACE FUNCTION processing_contains_error_chunks(jobExecId uuid)
RETURNS boolean AS $has_errors$
DECLARE
has_errors boolean;
BEGIN
SELECT count(id) > 0 INTO has_errors
FROM job_execution_source_chunks
WHERE (jsonb->>'jobExecutionId')::uuid = jobExecId AND jsonb->>'state' = 'ERROR';
RETURN has_errors;
END;
$has_errors$ LANGUAGE plpgsql;
|
<reponame>sara-nl/research-data-exchange
ALTER TABLE Shares ADD COLUMN user_metadata json;
|
<reponame>rubik-ai/koku
--
-- Copyright 2021 Red Hat Inc.
-- SPDX-License-Identifier: Apache-2.0
--
DROP FUNCTION IF EXISTS public.trfn_manage_date_range_partition();
CREATE OR REPLACE FUNCTION public.trfn_manage_date_range_partition() RETURNS TRIGGER AS $$
DECLARE
alter_stmt text = '';
action_stmt text = '';
alter_msg text = '';
action_msg text = '';
table_name text = '';
BEGIN
IF ( TG_OP = 'DELETE' )
THEN
IF ( OLD.active )
THEN
alter_stmt = 'ALTER TABLE ' ||
quote_ident(OLD.schema_name) || '.' || quote_ident(OLD.partition_of_table_name) ||
' DETACH PARTITION ' ||
quote_ident(OLD.schema_name) || '.' || quote_ident(OLD.table_name) ||
' ;';
END IF;
action_stmt = 'DROP TABLE IF EXISTS ' || quote_ident(OLD.schema_name) || '.' || quote_ident(OLD.table_name) || ' ;';
table_name = quote_ident(OLD.schema_name) || '.' || quote_ident(OLD.partition_of_table_name);
alter_msg = 'DROP PARTITION ' || quote_ident(OLD.schema_name) || '.' || quote_ident(OLD.table_name);
ELSIF ( TG_OP = 'UPDATE' )
THEN
/* If the partition was active, then detach it */
if ( OLD.active )
THEN
alter_stmt = 'ALTER TABLE ' ||
quote_ident(OLD.schema_name) || '.' || quote_ident(OLD.partition_of_table_name) ||
' DETACH PARTITION ' ||
quote_ident(OLD.schema_name) || '.' || quote_ident(OLD.table_name)
|| ' ;';
END IF;
/* If we are going to active or are still active, then attach the partition */
if ( NEW.active )
THEN
action_stmt = 'ALTER TABLE ' ||
quote_ident(OLD.schema_name) || '.' || quote_ident(OLD.partition_of_table_name) ||
' ATTACH PARTITION ' ||
quote_ident(OLD.schema_name) || '.' || quote_ident(OLD.table_name) || ' ';
IF ( (NEW.partition_parameters->>'default') = 'true' )
THEN
action_stmt = action_stmt || 'DEFAULT ;';
action_msg = 'DEFAULT';
ELSE
action_stmt = action_stmt || 'FOR VALUES FROM ( ' ||
quote_literal(NEW.partition_parameters->>'from') || '::date ) TO (' ||
quote_literal(NEW.partition_parameters->>'to') || '::date ) ;';
action_msg = 'FOR VALUES FROM ( ' ||
quote_literal(NEW.partition_parameters->>'from') || '::date ) TO (' ||
quote_literal(NEW.partition_parameters->>'to') || '::date )';
END IF;
END IF;
table_name = quote_ident(NEW.schema_name) || '.' || quote_ident(NEW.partition_of_table_name);
action_msg = 'ALTER PARTITION ' || quote_ident(NEW.schema_name) || '.' || quote_ident(NEW.table_name) ||
' ' || action_msg;
ELSIF ( TG_OP = 'INSERT' )
THEN
action_stmt = 'CREATE TABLE IF NOT EXISTS ' ||
quote_ident(NEW.schema_name) || '.' || quote_ident(NEW.table_name) || ' ' ||
'PARTITION OF ' ||
quote_ident(NEW.schema_name) || '.' || quote_ident(NEW.partition_of_table_name) || ' ';
IF ( (NEW.partition_parameters->>'default')::boolean )
THEN
action_stmt = action_stmt || 'DEFAULT ;';
action_msg = 'DEFAULT';
ELSE
action_stmt = action_stmt || 'FOR VALUES FROM ( ' ||
quote_literal(NEW.partition_parameters->>'from') || '::date ) TO (' ||
quote_literal(NEW.partition_parameters->>'to') || '::date ) ;';
action_msg = 'FOR VALUES FROM ( ' ||
quote_literal(NEW.partition_parameters->>'from') || '::date ) TO (' ||
quote_literal(NEW.partition_parameters->>'to') || '::date )';
END IF;
action_msg = 'CREATE PARTITION ' || quote_ident(NEW.schema_name) || '.' || quote_ident(NEW.table_name) ||
' ' || action_msg;
table_name = quote_ident(NEW.schema_name) || '.' || quote_ident(NEW.partition_of_table_name);
ELSE
RAISE EXCEPTION 'Unhandled trigger operation %', TG_OP;
END IF;
IF ( alter_stmt != '' )
THEN
IF ( alter_msg != '' )
THEN
RAISE NOTICE 'ALTER TABLE % : %', table_name, alter_msg;
END IF;
EXECUTE alter_stmt;
END IF;
IF ( action_stmt != '' )
THEN
IF ( action_msg != '' )
THEN
RAISE NOTICE 'ALTER TABLE % : %', table_name, action_msg;
END IF;
EXECUTE action_stmt;
END IF;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
|
create or replace function otools.collect_table_growth()
returns void
as $$
insert into otools.table_growth (table_owner, schema_name, table_name, actual_size, growth_size, sum_flag, capture_time)
select pg_get_userbyid(c.relowner) AS table_owner, n.nspname AS schema_name, c.relname AS table_name, pg_total_relation_size(c.oid), 0, 0, current_date
from pg_class c JOIN pg_namespace n ON (c.relnamespace=n.oid) where relkind = 'r' and reltuples > 10000;
$$ language sql;
|
<filename>module/Application/db/db-versioning/v1/testdata/set1/studentgroup_has_student.sql
START TRANSACTION;
INSERT INTO `studentgroup_has_student` (`id`, `studentgroup_id`, `student_id`, `insert_date`, `activationstatus_id`) VALUES (1, 1, 1, '2015-07-26 13:35:00', 1);
COMMIT; |
-- phpMyAdmin SQL Dump
-- version 4.8.2
-- https://www.phpmyadmin.net/
--
-- Servidor: localhost
-- Tiempo de generación: 16-08-2018 a las 19:34:15
-- Versión del servidor: 10.1.34-MariaDB
-- Versión de PHP: 7.2.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de datos: `todo`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `tasks`
--
CREATE TABLE `tasks` (
`id` int(11) NOT NULL,
`description` text NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`done` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Índices para tablas volcadas
--
--
-- Indices de la tabla `tasks`
--
ALTER TABLE `tasks`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT de las tablas volcadas
--
--
-- AUTO_INCREMENT de la tabla `tasks`
--
ALTER TABLE `tasks`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
-- Create a DB with 3 tables
DROP DATABASE IF EXISTS ems_db;
CREATE DATABASE ems_db;
USE ems_db;
CREATE TABLE department (
id INT NOT NULL AUTO_INCREMENT,
dept_name VARCHAR(30) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE empRole (
id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(30),
salary DECIMAL(10),
dept_id INT,
PRIMARY KEY (id),
FOREIGN KEY (dept_id) REFERENCES department(id)
);
CREATE TABLE employee (
id INT NOT NULL AUTO_INCREMENT,
firstname VARCHAR(30),
surname VARCHAR(30),
role_id INT NOT NULL,
manager_id INT,
manager BOOLEAN,
PRIMARY KEY (id),
FOREIGN KEY (role_id) REFERENCES empRole(id),
FOREIGN KEY (manager_id) REFERENCES employee(id)
);
-- ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<PASSWORD>' |
CREATE SEQUENCE m_products_seq;
CREATE TYPE category AS ENUM('shirt', 'trousers', 'pants', 'short');
CREATE TABLE m_products (
id int check (id > 0) NOT NULL DEFAULT NEXTVAL ('m_products_seq'),
created_at timestamp(0) NULL DEFAULT NULL,
updated_at timestamp(0) NULL DEFAULT NULL,
deleted_at timestamp(0) NULL DEFAULT NULL,
name varchar(255) NOT NULL,
category category NOT NULL,
variant_id int check (variant_id > 0) NOT NULL,
price DECIMAL(14, 2) DEFAULT NULL,
description text DEFAULT NULL,
quantity int DEFAULT NULL,
PRIMARY KEY (id),
CONSTRAINT fk_m_products_variant_id FOREIGN KEY (variant_id) REFERENCES m_variants (id) ON DELETE RESTRICT ON UPDATE CASCADE
);
CREATE INDEX m_products_deleted_at ON m_products (deleted_at);
|
USE AdventureWorks2019;
SELECT SalesPersonID, SalesYTD, SalesOrderID, PEP.FirstName, PEP.LastName
FROM Sales.SalesPerson as P
LEFT OUTER JOIN Sales.SalesOrderHeader AS S
ON P.BusinessEntityID = S.SalesPersonID
LEFT OUTER JOIN Person.Person as PEP
ON P.BusinessEntityID = PEP.BusinessEntityID |
<filename>4° Período/Programação Orientada a Objetos II/Sistema/out/production/Sistema/banco_sistema.sql
-- MySQL Script generated by MySQL Workbench
-- Tue Nov 10 10:38:39 2020
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`Cargo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Cargo` (
`idCargo` INT NOT NULL AUTO_INCREMENT,
`nome_cargo` VARCHAR(45) NULL,
`atribuicoes` VARCHAR(45) NULL,
PRIMARY KEY (`idCargo`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Setor`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Setor` (
`idSetor` INT NOT NULL AUTO_INCREMENT,
`nome_setor` VARCHAR(45) NULL,
`Gerente_id` INT NOT NULL,
PRIMARY KEY (`idSetor`),
INDEX `fk_Setor_Funcionario1_idx` (`Gerente_id` ASC) VISIBLE,
CONSTRAINT `fk_Setor_Funcionario1`
FOREIGN KEY (`Gerente_id`)
REFERENCES `mydb`.`Funcionario` (`idFuncionario`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Funcionario`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Funcionario` (
`idFuncionario` INT NOT NULL AUTO_INCREMENT,
`nome` VARCHAR(45) NULL,
`data_admisao` VARCHAR(10) NULL,
`data_recisao` VARCHAR(10) NULL,
`Cargo_id` INT NOT NULL,
`Setor_idSetor` INT NOT NULL,
PRIMARY KEY (`idFuncionario`),
INDEX `fk_Funcionario_Cargo_idx` (`Cargo_id` ASC) VISIBLE,
INDEX `fk_Funcionario_Setor1_idx` (`Setor_idSetor` ASC) VISIBLE,
CONSTRAINT `fk_Funcionario_Cargo`
FOREIGN KEY (`Cargo_id`)
REFERENCES `mydb`.`Cargo` (`idCargo`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Funcionario_Setor1`
FOREIGN KEY (`Setor_idSetor`)
REFERENCES `mydb`.`Setor` (`idSetor`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
<reponame>fjeller/Smarthouse.AspnetCore.Samples
USE [CustomerDatabase]
GO
/****** Object: Table [dbo].[Customers] Script Date: 10.10.2019 09:45:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Customers](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Lastname] [nvarchar](100) NOT NULL,
[FirstName] [nvarchar](100) NOT NULL,
[Email] [nvarchar](100) NOT NULL,
[IsActive] [bit] NOT NULL,
CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Tags] Script Date: 10.10.2019 09:45:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Tags](
[Id] [int] IDENTITY(1,1) NOT NULL,
[TagName] [nvarchar](100) NOT NULL,
CONSTRAINT [PK_Tags] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[TagsToCustomers] Script Date: 10.10.2019 09:45:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TagsToCustomers](
[CustomerId] [int] NOT NULL,
[TagId] [int] NOT NULL,
CONSTRAINT [PK_TagsToCustomers] PRIMARY KEY CLUSTERED
(
[CustomerId] ASC,
[TagId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.