Skip to content

Instantly share code, notes, and snippets.

@geshan
Created March 10, 2021 21:52
Show Gist options
  • Select an option

  • Save geshan/87f97f8b6332ab9acdda39605dadffa2 to your computer and use it in GitHub Desktop.

Select an option

Save geshan/87f97f8b6332ab9acdda39605dadffa2 to your computer and use it in GitHub Desktop.
Markdium-Node.js MySQL Transaction: a step-by-step tutorial with a real-life example
CREATE TABLE `product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`sku` char(6) COLLATE utf8_unicode_ci NOT NULL,
`price` int(11) NOT NULL COMMENT 'in cents',
`quantity` int(11) NOT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE INDEX `sku` (`sku` ASC) VISIBLE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `sales_order` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`items` text COLLATE utf8_unicode_ci NOT NULL,
`total` int(11) NOT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment