CREATE TABLE `internal` (
  `vname` varchar(15) NOT NULL,
  `vvalue` varchar(132) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `internal` (`vname`, `vvalue`) VALUES ('cleanup', '0');

INSERT INTO `internal` (`vname`, `vvalue`) VALUES ('lasttry', '0');

CREATE TABLE `daemonlog` (
  `logid` int(11) NOT NULL,
  `status` text NOT NULL,
  `timestamp` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


ALTER TABLE `daemonlog`
  ADD PRIMARY KEY (`logid`);


ALTER TABLE `daemonlog`
  MODIFY `logid` int(11) NOT NULL AUTO_INCREMENT;COMMIT;

UPDATE `tabledefs` SET `sqlquery` = 'select displayid as id, displayname as val from displays where displays.allorders=0 order by displayname asc' WHERE `tabledefs`.`defid` = 38;

UPDATE `tabledefs` SET `sqlquery` = 'select displayid as id, displayname as val from displays where displays.allorders=0 order by displayname asc' WHERE `tabledefs`.`defid` = 39;

ALTER TABLE `assetmgr` ADD `sqlonsave` TEXT NOT NULL AFTER `returnname`;

UPDATE `assetmgr` SET `sqlonsave` = 'delete from relmenudisplays where (valueid) in (select displayid from displays where displays.allorders=1); delete from relmodifierdisplay where (valueid) in (select displayid from displays where displays.allorders=1);' WHERE `assetmgr`.`assetid` = 1;

ALTER TABLE `displays` ADD `autobump` BOOLEAN NOT NULL DEFAULT FALSE AFTER `pendingreboot`;

INSERT INTO `tabledefs` (`defid`, `tablename`, `settingname`, `actualfield`, `datatype`, `fielddescription`, `isid`, `showintable`, `editable`, `ordinality`, `sqlquery`, `relationshiptable`, `displaysql`, `defaultvalue`) VALUES (NULL, 'displays', 'Auto Bump?', 'autobump', 'dropdown', 'Automatically Bump Orders Sent to this display? (This is useful for print-only stations)', '0', '1', '1', '51', 'select valueid as id, valuename as val from booleanddl order by valueid asc', '', 'select valueid as id, valuename as val from booleanddl where valueid=\'%id%\'', '');

DELETE FROM `permissions` WHERE `permissions`.`id` = 8;
INSERT INTO `permissions` (`id`, `permission`) VALUES (NULL, 'Review My Payments'), (NULL, 'Review All Payments');

INSERT INTO `tabledefs` (`defid`, `tablename`, `settingname`, `actualfield`, `datatype`, `fielddescription`, `isid`, `showintable`, `editable`, `ordinality`, `sqlquery`, `relationshiptable`, `displaysql`, `defaultvalue`) VALUES (NULL, 'menuitems', 'Maximum Item Price', 'maxprice', 'number', 'This is the Maximum price for this item with or without required modifiers. ', '0', '1', '1', '10', '', '', '', '');

INSERT INTO `tabledefs` (`defid`, `tablename`, `settingname`, `actualfield`, `datatype`, `fielddescription`, `isid`, `showintable`, `editable`, `ordinality`, `sqlquery`, `relationshiptable`, `displaysql`, `defaultvalue`) VALUES (NULL, 'modifiers', 'Maximum Item Price', 'maxprice', 'number', 'This is the maximum total price for this item with or without required modifiers. ', '0', '1', '1', '10', '', '', '', '');

ALTER TABLE `menuitems` ADD `maxprice` DECIMAL(10,2) NOT NULL DEFAULT '0' AFTER `delaygroup`;

ALTER TABLE `modifiers` ADD `maxprice` DECIMAL(10,2) NOT NULL DEFAULT '0' AFTER `delaygroup`;
ALTER TABLE `orderitems` ADD `maxprice` DECIMAL(10,2) NOT NULL DEFAULT '0' AFTER `minprice`;
ALTER TABLE `modifiergroups` ADD `displayname` VARCHAR(132) NOT NULL AFTER `pricetiergroup`;
INSERT INTO `tabledefs` (`defid`, `tablename`, `settingname`, `actualfield`, `datatype`, `fielddescription`, `isid`, `showintable`, `editable`, `ordinality`, `sqlquery`, `relationshiptable`, `displaysql`, `defaultvalue`) VALUES (NULL, 'modifiergroups', 'Mod Group Display Name', 'displayname', 'text', 'Name of your Modifier Group as Shown on Order Screen. (Example: Toppings, sizes, temperatures) If left blank, Group Name will be used.', '0', '1', '1', '0', '', '', '', '');