-- -------------------------------------------------------------
-- TablePlus 6.7.0(634)
--
-- https://tableplus.com/
--
-- Database: sx_db_1751480457
-- Generation Time: 2025-09-12 12:25:08.5630
-- -------------------------------------------------------------


/*!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 */;
/*!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 */;


CREATE TABLE `transaction_item` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `refid` bigint(20) unsigned DEFAULT NULL,
  `external_id` varchar(255) DEFAULT NULL,
  `synced` tinyint(1) NOT NULL DEFAULT 0,
  `fields` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`fields`)),
  `amount` decimal(15,2) NOT NULL,
  `line` int(11) DEFAULT NULL,
  `cleared` tinyint(1) NOT NULL DEFAULT 0,
  `commitmentfirm` tinyint(1) NOT NULL DEFAULT 0,
  `costestimate` decimal(15,2) DEFAULT NULL,
  `costestimatebase` decimal(15,2) DEFAULT NULL,
  `costestimaterate` decimal(15,2) DEFAULT NULL,
  `costestimatetype` varchar(255) DEFAULT NULL,
  `createdfrom` bigint(20) unsigned DEFAULT NULL,
  `creditforeignamount` decimal(15,2) DEFAULT NULL,
  `donotcreaterevenueelement` tinyint(1) NOT NULL DEFAULT 0,
  `donotdisplayline` tinyint(1) NOT NULL DEFAULT 0,
  `dropship` tinyint(1) NOT NULL DEFAULT 0,
  `entity` bigint(20) unsigned DEFAULT NULL,
  `estgrossprofit` decimal(15,2) DEFAULT NULL,
  `estgrossprofitpercent` decimal(15,6) DEFAULT NULL,
  `expenseaccount` bigint(20) unsigned DEFAULT NULL,
  `foreignamount` decimal(15,2) DEFAULT NULL,
  `fulfillable` tinyint(1) NOT NULL DEFAULT 0,
  `hasfulfillableitems` tinyint(1) NOT NULL DEFAULT 0,
  `isbillable` tinyint(1) NOT NULL DEFAULT 0,
  `isclosed` tinyint(1) NOT NULL DEFAULT 0,
  `iscogs` tinyint(1) NOT NULL DEFAULT 0,
  `iscustomglline` tinyint(1) NOT NULL DEFAULT 0,
  `isdisplayedinpaycheck` tinyint(1) NOT NULL DEFAULT 0,
  `isestimate` tinyint(1) NOT NULL DEFAULT 0,
  `isfullyshipped` tinyint(1) NOT NULL DEFAULT 0,
  `isfxvariance` tinyint(1) NOT NULL DEFAULT 0,
  `isinventoryaffecting` tinyint(1) NOT NULL DEFAULT 0,
  `isrevrectransaction` tinyint(1) NOT NULL DEFAULT 0,
  `item` bigint(20) unsigned DEFAULT NULL,
  `itemtype` varchar(255) DEFAULT NULL,
  `kitcomponent` tinyint(1) NOT NULL DEFAULT 0,
  `linelastmodifieddate` datetime DEFAULT NULL,
  `linesequencenumber` int(11) DEFAULT NULL,
  `mainline` tinyint(1) NOT NULL DEFAULT 0,
  `matchbilltoreceipt` tinyint(1) NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `needsrevenueelement` tinyint(1) NOT NULL DEFAULT 0,
  `netamount` decimal(15,2) DEFAULT NULL,
  `oldcommitmentfirm` tinyint(1) NOT NULL DEFAULT 0,
  `price` int(11) DEFAULT NULL,
  `quantity` int(11) NOT NULL DEFAULT 0,
  `quantitybilled` int(11) NOT NULL DEFAULT 0,
  `quantityrejected` int(11) NOT NULL DEFAULT 0,
  `quantityrequestedtofulfill` int(11) NOT NULL DEFAULT 0,
  `quantityshiprecv` int(11) NOT NULL DEFAULT 0,
  `rate` decimal(15,2) DEFAULT NULL,
  `rateamount` decimal(15,2) DEFAULT NULL,
  `specialorder` tinyint(1) NOT NULL DEFAULT 0,
  `subsidiary` bigint(20) unsigned DEFAULT NULL,
  `taxline` tinyint(1) NOT NULL DEFAULT 0,
  `transaction` bigint(20) unsigned DEFAULT NULL,
  `transactiondiscount` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `transaction_item_external_id_unique` (`external_id`),
  KEY `transaction_item_transaction_foreign` (`transaction`),
  KEY `transaction_item_item_foreign` (`item`),
  KEY `transaction_item_refid_index` (`refid`),
  CONSTRAINT `transaction_item_item_foreign` FOREIGN KEY (`item`) REFERENCES `items` (`id`) ON DELETE CASCADE,
  CONSTRAINT `transaction_item_transaction_foreign` FOREIGN KEY (`transaction`) REFERENCES `transactions_old` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



/*!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 */;