-- --------------------------------------------------------
-- Host:                         localhost
-- Server version:               5.7.24 - MySQL Community Server (GPL)
-- Server OS:                    Win64
-- HeidiSQL Version:             10.1.0.5484
-- --------------------------------------------------------

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


-- Dumping structure for table myconnection.migration
CREATE TABLE IF NOT EXISTS `migration` (
  `version` varchar(180) NOT NULL,
  `apply_time` int(11) DEFAULT NULL,
  PRIMARY KEY (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- Dumping data for table myconnection.migration: ~2 rows (approximately)
DELETE FROM `migration`;
/*!40000 ALTER TABLE `migration` DISABLE KEYS */;
INSERT INTO `migration` (`version`, `apply_time`) VALUES
  ('m000000_000000_base', 1548917531),
  ('m130524_201442_init', 1548917544);
/*!40000 ALTER TABLE `migration` ENABLE KEYS */;

-- Dumping structure for table myconnection.sync_account_to_jurnal
CREATE TABLE IF NOT EXISTS `sync_account_to_jurnal` (
  `payment_fpkey` int(11) NOT NULL,
  `payment_type` varchar(90) DEFAULT NULL,
  `nama_akun` varchar(90) DEFAULT NULL,
  PRIMARY KEY (`payment_fpkey`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- Dumping structure for table myconnection.sync_config
CREATE TABLE IF NOT EXISTS `sync_config` (
  `inventory_account_number` varchar(20) DEFAULT NULL,
  `asset_account_name` varchar(40) NOT NULL DEFAULT '',
  `income_account_name` varchar(40) NOT NULL DEFAULT '',
  `tax_name` varchar(40) DEFAULT NULL,
  `branch_code` varchar(10) NOT NULL,
  `branch_name` varchar(255) DEFAULT NULL,
  `api_key` varchar(50) DEFAULT NULL,
  `jurnal_referral` varchar(40) NOT NULL DEFAULT 'INTERACTIVE',
  PRIMARY KEY (`branch_code`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `sync_config` (`inventory_account_number`, `asset_account_name`, `income_account_name`, `tax_name`, `branch_code`, `branch_name`, `api_key`, `jurnal_referral`, `type_con`) VALUES
  ('', '', '', '', 'RST', '', '', 'INTERACTIVE', 'resto'),
  ('', '', '', '', 'RTL', '', '', 'INTERACTIVE', 'retail');


-- Dumping structure for table myconnection.sync_to_jurnal
CREATE TABLE IF NOT EXISTS `sync_to_jurnal` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `last_update` datetime DEFAULT NULL,
  `tipe_tabel` varchar(255) DEFAULT NULL,
  `id_record` int(11) NOT NULL,
  `status_sinkron` varchar(10) DEFAULT NULL,
  `keterangan` text,
  `id_jurnal` double DEFAULT NULL,
  `tipe_proses` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=latin1;

-- Dumping structure for table myconnection.user
CREATE TABLE IF NOT EXISTS `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `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 '10',
  `created_at` int(11) NOT NULL,
  `updated_at` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`),
  UNIQUE KEY `email` (`email`),
  UNIQUE KEY `password_reset_token` (`password_reset_token`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Dumping data for table myconnection.user: ~2 rows (approximately)
DELETE FROM `user`;
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
INSERT INTO `user` (`id`, `username`, `auth_key`, `password_hash`, `password_reset_token`, `email`, `status`, `created_at`, `updated_at`) VALUES
  (1, 'superadmin', 'r8XrNVPIohnjQoAgMbXlafbsX_6BG3L5', '$2y$13$68JozPKu.UepfQiPYBBkIOT5T.yHDDwhujB0LCF6/BJVfPw9eey6K', NULL, 'admin@interactive.co.id', 10, 1548917768, 1552621311);
/*!40000 ALTER TABLE `user` ENABLE KEYS */;

ALTER TABLE sync_to_jurnal ADD type_con ENUM('retail','resto');
ALTER TABLE sync_config ADD type_con ENUM('retail','resto');
ALTER TABLE sync_account_to_jurnal ADD type_con ENUM('retail','resto');
ALTER TABLE `sync_account_to_jurnal`
  ALTER `type_con` DROP DEFAULT;
ALTER TABLE `sync_account_to_jurnal`
  CHANGE COLUMN `type_con` `type_con` ENUM('retail','resto') NOT NULL AFTER `nama_akun`,
  DROP PRIMARY KEY,
  ADD PRIMARY KEY (`payment_fpkey`, `type_con`);


UPDATE sync_account_to_jurnal SET type_con = 'resto' WHERE type_con IS NULL;
UPDATE sync_config SET type_con = 'resto' WHERE type_con IS NULL;
UPDATE sync_to_jurnal SET type_con = 'resto' WHERE type_con IS NULL;

CREATE TABLE `sync_to_jurnal_header` (                     
 `id_header` int(11) NOT NULL auto_increment,             
 `jenis_sinkron` enum('manual','otomatis') default NULL,  
 `jenis_data` enum('master','transaksi') default NULL,
 `date_created` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
 `type_con` enum('resto','retail') default 'resto',
 PRIMARY KEY  (`id_header`)                               
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE sync_to_jurnal ADD COLUMN id_header int(11) AFTER id;

/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
