PageRenderTime 9ms CodeModel.GetById 180ms app.highlight 382ms RepoModel.GetById 31ms app.codeStats 1ms

/install/sql/yabs-1.0-mysql.sql

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
SQL | 1664 lines | 1373 code | 291 blank | 0 comment | 5 complexity | 1563e2bb43f346abb65349b04f175d3a MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1CREATE TABLE accounts  (
   2	ids             	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
   3	intaccountclass 	SMALLINT DEFAULT 0,
   4	cname           	VARCHAR(250) NOT NULL,
   5	description     	VARCHAR(250) NOT NULL,
   6	taxvalue        	DOUBLE NOT NULL DEFAULT 0,
   7	dateadded       	DATE NOT NULL,
   8	intaddedby      	BIGINT(20) DEFAULT 0,
   9	intparentaccount	BIGINT(20) DEFAULT 0,
  10	groupsids       	BIGINT(20) UNSIGNED NOT NULL  DEFAULT 1,
  11	invisible       	SMALLINT DEFAULT 0,
  12	intaccounttype  	SMALLINT NOT NULL,
  13	intprofitfid    	SMALLINT NOT NULL,
  14	inttaxfid       	SMALLINT NOT NULL,
  15	inttaxuid       	SMALLINT NOT NULL,
  16	frame           	VARCHAR(25) NOT NULL,
  17	hierarchypath   	VARCHAR(250) DEFAULT NULL
  18)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
  19
  20CREATE TABLE addresses  (
  21	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
  22	groupsids  	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
  23	contactsids	BIGINT(20) UNSIGNED NOT NULL ,
  24	title      	VARCHAR(250) DEFAULT NULL,
  25	taxnumber  	VARCHAR(250) DEFAULT NULL,
  26	prename    	VARCHAR(250) DEFAULT NULL,
  27	cname      	VARCHAR(250) DEFAULT NULL,
  28	street     	VARCHAR(250) DEFAULT NULL,
  29	zip        	VARCHAR(50) DEFAULT NULL,
  30	city       	VARCHAR(300) DEFAULT NULL,
  31	company    	VARCHAR(250) DEFAULT NULL,
  32	department 	VARCHAR(250) DEFAULT NULL,
  33	country    	VARCHAR(50) DEFAULT NULL,
  34	ismale     	SMALLINT DEFAULT 0,
  35	intaddedby 	BIGINT(20) DEFAULT 0,
  36	dateadded  	DATE DEFAULT NULL,
  37	inttype    	SMALLINT DEFAULT 0,
  38	reserve1   	VARCHAR(500) DEFAULT NULL,
  39	reserve2   	VARCHAR(500) DEFAULT NULL
  40)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
  41
  42CREATE TABLE comps  (
  43	ids          	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
  44	groupsids    	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
  45	cname        	VARCHAR(250) DEFAULT NULL,
  46	state        	VARCHAR(250) DEFAULT NULL,
  47	phoneprefix  	VARCHAR(250) DEFAULT NULL,
  48	business     	VARCHAR(250) DEFAULT NULL,
  49	taxadvisor   	VARCHAR(250) DEFAULT NULL,
  50	city         	VARCHAR(250) DEFAULT NULL,
  51	taxadvjob    	VARCHAR(250) DEFAULT NULL,
  52	street       	VARCHAR(250) DEFAULT NULL,
  53	stb          	VARCHAR(250) DEFAULT NULL,
  54	email        	VARCHAR(250) DEFAULT NULL,
  55	name         	VARCHAR(250) DEFAULT NULL,
  56	zipcode      	VARCHAR(250) DEFAULT NULL,
  57	phone        	VARCHAR(250) DEFAULT NULL,
  58	firstname    	VARCHAR(250) DEFAULT NULL,
  59	taxauthority 	VARCHAR(250) DEFAULT NULL,
  60	taxnumber    	VARCHAR(250) DEFAULT NULL,
  61	taxadvmandant	VARCHAR(250) DEFAULT NULL,
  62	dateadded    	DATE NOT NULL,
  63	ismale       	SMALLINT DEFAULT 0,
  64	isenabled    	SMALLINT DEFAULT 1,
  65	intaddedby   	BIGINT(20) DEFAULT 0,
  66	invisible    	SMALLINT DEFAULT 0,
  67	reserve1     	VARCHAR(500) DEFAULT NULL,
  68	reserve2     	VARCHAR(500) DEFAULT NULL
  69)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
  70
  71CREATE TABLE contacts  (
  72	ids           	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
  73	cnumber       	VARCHAR(250) DEFAULT NULL,
  74	taxnumber     	VARCHAR(250),
  75	title         	VARCHAR(250) DEFAULT NULL,
  76	groupsids     	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
  77	country       	VARCHAR(50) DEFAULT NULL,
  78	prename       	VARCHAR(250) DEFAULT NULL,
  79	cname         	VARCHAR(250) DEFAULT NULL,
  80	street        	VARCHAR(250) DEFAULT NULL,
  81	zip           	VARCHAR(50) DEFAULT NULL,
  82	city          	VARCHAR(300) DEFAULT NULL,
  83	mainphone     	VARCHAR(250) DEFAULT NULL,
  84	fax           	VARCHAR(250) DEFAULT NULL,
  85	mobilephone   	VARCHAR(250) DEFAULT NULL,
  86	workphone     	VARCHAR(250) DEFAULT NULL,
  87	mailaddress   	VARCHAR(350) DEFAULT NULL,
  88	company       	VARCHAR(250) DEFAULT NULL,
  89	department    	VARCHAR(250) DEFAULT NULL,
  90	website       	VARCHAR(350) DEFAULT NULL,
  91	notes         	VARCHAR(10000),
  92	dateadded     	DATE NOT NULL,
  93	isactive      	SMALLINT DEFAULT 0,
  94	iscustomer    	SMALLINT DEFAULT 0,
  95	ismanufacturer	SMALLINT DEFAULT 0,
  96	issupplier    	SMALLINT DEFAULT 0,
  97	iscompany     	SMALLINT DEFAULT 0,
  98	ismale        	SMALLINT DEFAULT 0,
  99	isenabled     	SMALLINT DEFAULT 1,
 100	intaddedby    	BIGINT(20) DEFAULT 0,
 101	invisible     	SMALLINT DEFAULT 0,
 102	reserve1      	VARCHAR(500) DEFAULT NULL,
 103	reserve2      	VARCHAR(500) DEFAULT NULL
 104)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 105
 106CREATE TABLE countries  (
 107	ids      	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 108	cname    	VARCHAR(250) NOT NULL,
 109	iso      	SMALLINT NOT NULL,
 110	groupsids	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 111	reserve1 	VARCHAR(500) DEFAULT NULL,
 112	reserve2 	VARCHAR(500) DEFAULT NULL
 113)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 114
 115CREATE TABLE expenses  (
 116	ids            	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 117	groupsids      	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 118	cnumber        	VARCHAR(250) DEFAULT NULL,
 119	cname          	VARCHAR(250) DEFAULT NULL,
 120	accountsids    	BIGINT(20) UNSIGNED NOT NULL ,
 121	netvalue       	DOUBLE DEFAULT 0,
 122	taxpercentvalue	DOUBLE DEFAULT 0,
 123	brutvalue      	DOUBLE DEFAULT 0,
 124	description    	VARCHAR(5000) DEFAULT NULL,
 125	dateadded      	DATE NOT NULL,
 126	intaddedby     	BIGINT(20) DEFAULT 0,
 127	invisible      	SMALLINT DEFAULT 0,
 128	reserve1       	VARCHAR(500) DEFAULT NULL,
 129	reserve2       	VARCHAR(500) DEFAULT NULL
 130)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 131
 132CREATE TABLE favourites  (
 133	ids       	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 134	cname     	VARCHAR(250) NOT NULL,
 135	usersids  	BIGINT(20) UNSIGNED NOT NULL ,
 136	groupsids 	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 137	itemsids  	BIGINT(20) UNSIGNED NOT NULL NOT NULL,
 138	dateadded 	DATE NOT NULL,
 139	intaddedby	BIGINT(20) DEFAULT 0,
 140	invisible 	SMALLINT DEFAULT 0,
 141	reserve1  	VARCHAR(500) DEFAULT NULL,
 142	reserve2  	VARCHAR(500) DEFAULT NULL
 143)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 144
 145CREATE TABLE files  (
 146	ids       	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 147	cname     	VARCHAR(25) NOT NULL,
 148	groupsids 	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 149	dateadded 	DATE NOT NULL,
 150	data      	BLOB(5242880) NOT NULL,
 151	filesize  	BIGINT(20) NOT NULL,
 152	intaddedby	BIGINT(20) DEFAULT 0,
 153	invisible 	SMALLINT DEFAULT 0
 154)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 155
 156CREATE TABLE filestocontacts  (
 157	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 158	cname      	VARCHAR(250) NOT NULL,
 159	description	VARCHAR(550) DEFAULT NULL,
 160	contactsids	BIGINT(20) UNSIGNED NOT NULL NOT NULL,
 161	filename   	VARCHAR(25) NOT NULL,
 162	intsize    	BIGINT(20) DEFAULT 0,
 163	mimetype   	VARCHAR(25) DEFAULT NULL,
 164	intaddedby 	BIGINT(20) DEFAULT 0,
 165	dateadded  	DATE NOT NULL,
 166	groupsids  	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1
 167)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 168
 169CREATE TABLE filestoitems  (
 170	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 171	cname      	VARCHAR(250) NOT NULL,
 172	description	VARCHAR(550) DEFAULT NULL,
 173	itemsids   	BIGINT(20) UNSIGNED NOT NULL NOT NULL,
 174	filename   	VARCHAR(25) NOT NULL,
 175	intsize    	BIGINT(20) DEFAULT 0,
 176	mimetype   	VARCHAR(25) DEFAULT NULL,
 177	intaddedby 	BIGINT(20) DEFAULT 0,
 178	dateadded  	DATE NOT NULL,
 179	groupsids  	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1
 180)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 181
 182CREATE TABLE filestoproducts  (
 183	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 184	cname      	VARCHAR(250) NOT NULL,
 185	description	VARCHAR(550) DEFAULT NULL,
 186	productsids	BIGINT(20) UNSIGNED NOT NULL NOT NULL,
 187	filename   	VARCHAR(25) NOT NULL,
 188	intsize    	BIGINT(20) DEFAULT 0,
 189	mimetype   	VARCHAR(25) DEFAULT NULL,
 190	intaddedby 	BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
 191	dateadded  	DATE NOT NULL,
 192	groupsids  	BIGINT(20)  UNSIGNED NOT NULL DEFAULT 1
 193)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 194
 195CREATE TABLE formatstousers  (
 196	ids     	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 197	cname   	VARCHAR(250) NOT NULL,
 198	usersids	BIGINT(20) UNSIGNED NOT NULL ,
 199	inttype 	SMALLINT DEFAULT 0
 200)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 201
 202CREATE TABLE globalsettings  (
 203	ids      	BIGINT(20) DEFAULT 1,
 204	cname    	VARCHAR(250) NOT NULL,
 205	groupsids	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 206	value    	VARCHAR(250) NOT NULL
 207	)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 208
 209CREATE TABLE groups  (
 210	ids          	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 211	cname        	VARCHAR(250) NOT NULL,
 212	description  	VARCHAR(750) DEFAULT NULL,
 213	defaults     	VARCHAR(250) DEFAULT NULL,
 214	groupsids    	BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
 215	dateadded    	DATE NOT NULL,
 216	reserve1     	VARCHAR(500) DEFAULT NULL,
 217	intaddedby   	BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
 218	hierarchypath	VARCHAR(500) DEFAULT NULL,
 219	reserve2     	VARCHAR(500) DEFAULT NULL
 220)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 221
 222CREATE TABLE history  (
 223	ids       	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 224	cname     	VARCHAR(250) NOT NULL,
 225	username  	VARCHAR(250) NOT NULL,
 226	dbidentity	VARCHAR(25) NOT NULL,
 227	intitem   	SMALLINT NOT NULL,
 228	groupsids 	BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
 229	dateadded 	DATE NOT NULL,
 230	intaddedby	BIGINT(20) DEFAULT 0,
 231	reserve1  	VARCHAR(500) DEFAULT NULL,
 232	reserve2  	VARCHAR(500) DEFAULT NULL
 233)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 234
 235CREATE TABLE items  (
 236	ids          	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 237	cname        	VARCHAR(250) NOT NULL,
 238	cnumber      	VARCHAR(250) NOT NULL,
 239	description  	VARCHAR(2500) DEFAULT NULL,
 240	groupsids    	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 241	accountsids  	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 242	contactsids  	BIGINT(20) UNSIGNED NOT NULL ,
 243	netvalue     	DOUBLE DEFAULT 0,
 244	taxvalue     	DOUBLE DEFAULT 0,
 245	discountvalue	DOUBLE DEFAULT 0,
 246	shippingvalue	DOUBLE DEFAULT 0,
 247	datetodo     	DATE DEFAULT NULL,
 248	dateend      	DATE DEFAULT NULL,
 249	intreminders 	INTEGER DEFAULT 0,
 250	inttype      	SMALLINT DEFAULT 0,
 251	dateadded    	DATE NOT NULL,
 252	intaddedby   	BIGINT(20) DEFAULT 0,
 253	invisible    	SMALLINT DEFAULT 0,
 254	intstatus    	SMALLINT DEFAULT 0,
 255	hierarchypath	VARCHAR(500) DEFAULT NULL,
 256	reserve1     	VARCHAR(500) DEFAULT NULL,
 257	reserve2     	VARCHAR(500) DEFAULT NULL
 258)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 259
 260CREATE TABLE itemstoaccounts  (
 261	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 262	itemsids   	BIGINT(20) UNSIGNED NOT NULL NOT NULL,
 263	accountsids	BIGINT(20) UNSIGNED NOT NULL ,
 264	reserve1   	VARCHAR(500) DEFAULT NULL,
 265	reserve2   	VARCHAR(500) DEFAULT NULL
 266)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 267
 268CREATE TABLE languages  (
 269	ids       	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 270	cname     	VARCHAR(250) NOT NULL,
 271	groupsids 	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 272	longname  	VARCHAR(250) NOT NULL,
 273	filename  	VARCHAR(25) NOT NULL,
 274	dateadded 	DATE NOT NULL,
 275	intaddedby	BIGINT(20) DEFAULT 0,
 276	invisible 	SMALLINT DEFAULT 0,
 277	reserve1  	VARCHAR(500) DEFAULT NULL,
 278	reserve2  	VARCHAR(500) DEFAULT NULL
 279)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 280
 281CREATE TABLE mails  (
 282	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 283	cname      	VARCHAR(1000) NOT NULL,
 284	dateadded  	DATE NOT NULL,
 285	intaddedby 	BIGINT(20) DEFAULT 0,
 286	groupsids  	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 287	invisible  	SMALLINT DEFAULT 0,
 288	usersids   	BIGINT(20) UNSIGNED NOT NULL ,
 289	description	VARCHAR(5000) NOT NULL
 290)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 291
 292CREATE TABLE plugins  (
 293	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 294	cname      	VARCHAR(250) NOT NULL,
 295	description	VARCHAR(550) DEFAULT NULL,
 296	filename   	VARCHAR(25) NOT NULL,
 297	intaddedby 	BIGINT(20) DEFAULT 0,
 298	dateadded  	DATE NOT NULL,
 299	groupsids  	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1
 300)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 301
 302CREATE TABLE pluginstousers  (
 303	ids       	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 304	cname     	VARCHAR(250) NOT NULL,
 305	usersids  	BIGINT(20) UNSIGNED NOT NULL NOT NULL,
 306	pluginsids	BIGINT(20) UNSIGNED NOT NULL NOT NULL,
 307	intaddedby	BIGINT(20) DEFAULT 0,
 308	dateadded 	DATE NOT NULL,
 309	groupsids 	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1
 310)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 311
 312CREATE TABLE productgroups  (
 313	ids             	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 314	cname           	VARCHAR(250) NOT NULL,
 315	description     	VARCHAR(750) DEFAULT NULL,
 316	defaults        	VARCHAR(250) DEFAULT NULL,
 317	groupsids       	BIGINT(20) UNSIGNED NOT NULL  DEFAULT 0,
 318	productgroupsids	BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
 319	dateadded       	DATE NOT NULL,
 320	hierarchypath   	VARCHAR(500) DEFAULT NULL,
 321	reserve1        	VARCHAR(500) DEFAULT NULL,
 322	intaddedby      	BIGINT(20) DEFAULT 0,
 323	reserve2        	VARCHAR(500) DEFAULT NULL
 324)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 325
 326CREATE TABLE productlistitems  (
 327	ids                	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 328	cname              	VARCHAR(2500) DEFAULT NULL,
 329	linkurl            	VARCHAR(250) DEFAULT NULL,
 330	groupsids          	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 331	productlistsids    	BIGINT(20) UNSIGNED NOT NULL ,
 332	originalproductsids	BIGINT(20) UNSIGNED NOT NULL ,
 333	countvalue         	DOUBLE NOT NULL DEFAULT 0,
 334	quantityvalue      	DOUBLE NOT NULL DEFAULT 0,
 335	measure            	VARCHAR(250) NOT NULL,
 336	description        	VARCHAR(1000) DEFAULT NULL,
 337	internalvalue      	DOUBLE DEFAULT 0,
 338	totalnetvalue      	DOUBLE DEFAULT 0,
 339	totalbrutvalue     	DOUBLE DEFAULT 0,
 340	externalvalue      	DOUBLE DEFAULT 0,
 341	taxpercentvalue    	DOUBLE NOT NULL DEFAULT 0,
 342	dateadded          	DATE NOT NULL,
 343	intaddedby         	BIGINT(20) DEFAULT 0,
 344	invisible          	SMALLINT DEFAULT 0,
 345	reserve1           	VARCHAR(500) DEFAULT NULL,
 346	reserve2           	VARCHAR(500) DEFAULT NULL
 347)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 348
 349CREATE TABLE productlists  (
 350	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 351	cname      	VARCHAR(2500) DEFAULT NULL,
 352	groupsids  	BIGINT(20) UNSIGNED NOT NULL  DEFAULT 1,
 353	description	VARCHAR(1000) DEFAULT NULL,
 354	dateadded  	DATE NOT NULL,
 355	intaddedby 	BIGINT(20) DEFAULT 0,
 356	invisible  	SMALLINT DEFAULT 0,
 357	reserve1   	VARCHAR(500) DEFAULT NULL,
 358	reserve2   	VARCHAR(500) DEFAULT NULL
 359)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 360
 361CREATE TABLE products  (
 362	ids             	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 363	cname           	VARCHAR(500) NOT NULL,
 364	cnumber         	VARCHAR(250) NOT NULL,
 365	description     	VARCHAR(5000),
 366	externalnetvalue	DOUBLE DEFAULT 0,
 367	internalnetvalue	DOUBLE DEFAULT 0,
 368	measure         	VARCHAR(250) NOT NULL,
 369	taxids          	BIGINT(20) UNSIGNED NOT NULL ,
 370	manufacturersids	BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
 371	suppliersids    	BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
 372	groupsids       	BIGINT(20) UNSIGNED NOT NULL  DEFAULT 1,
 373	productgroupsids	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 374	url             	VARCHAR(250) DEFAULT NULL,
 375	ean             	VARCHAR(25) DEFAULT NULL,
 376	reference       	VARCHAR(50) DEFAULT NULL,
 377	dateadded       	DATE NOT NULL,
 378	intaddedby      	BIGINT(20) DEFAULT 0,
 379	invisible       	SMALLINT DEFAULT 0,
 380	inttype         	SMALLINT NOT NULL,
 381	defaultimage    	VARCHAR(30) DEFAULT NULL,
 382	reserve1        	VARCHAR(500) DEFAULT NULL,
 383	reserve2        	VARCHAR(500) DEFAULT NULL
 384)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 385
 386CREATE TABLE reminders  (
 387	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 388	cname      	VARCHAR(250) NOT NULL,
 389	description	VARCHAR(550) DEFAULT NULL,
 390	stagesids  	BIGINT(20) UNSIGNED NOT NULL,
 391	itemsids   	BIGINT(20) UNSIGNED NOT NULL,
 392	extravalue 	DOUBLE DEFAULT 0,
 393	intaddedby 	BIGINT(20) DEFAULT 0,
 394	dateadded  	DATE NOT NULL,
 395	groupsids  	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1
 396)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 397
 398CREATE TABLE revenues  (
 399	ids            	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 400	groupsids      	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 401	cnumber        	VARCHAR(250) DEFAULT NULL,
 402	cname          	VARCHAR(250) DEFAULT NULL,
 403	accountsids    	BIGINT(20) UNSIGNED NOT NULL,
 404	netvalue       	DOUBLE DEFAULT 0,
 405	taxpercentvalue	DOUBLE DEFAULT 0,
 406	brutvalue      	DOUBLE DEFAULT 0,
 407	description    	VARCHAR(5000) DEFAULT NULL,
 408	dateadded      	DATE NOT NULL,
 409	intaddedby     	BIGINT(20) DEFAULT 0,
 410	invisible      	SMALLINT DEFAULT 0,
 411	reserve1       	VARCHAR(500) DEFAULT NULL,
 412	reserve2       	VARCHAR(500) DEFAULT NULL
 413)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 414
 415CREATE TABLE schedule  (
 416	ids          	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 417	cname        	VARCHAR(250) NOT NULL,
 418	groupsids    	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 419	usersids     	BIGINT(20) UNSIGNED NOT NULL ,
 420	itemsids     	BIGINT(20) UNSIGNED NOT NULL ,
 421	stopdate     	DATE NOT NULL,
 422	startdate    	DATE NOT NULL,
 423	nextdate     	DATE NOT NULL,
 424	isdone       	SMALLINT DEFAULT 0,
 425	intervalmonth	SMALLINT NOT NULL,
 426	dateadded    	DATE NOT NULL,
 427	intaddedby   	BIGINT(20) DEFAULT 0,
 428	invisible    	SMALLINT DEFAULT 0,
 429	reserve1     	VARCHAR(500) DEFAULT NULL,
 430	reserve2     	VARCHAR(500) DEFAULT NULL
 431)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 432
 433CREATE TABLE searchindex  (
 434	ids       	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 435	dbidentity	VARCHAR(25) NOT NULL,
 436	groupsids 	BIGINT(20) UNSIGNED NOT NULL ,
 437	rowid     	BIGINT(20) NOT NULL,
 438	text      	VARCHAR(5000) DEFAULT NULL
 439	)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 440
 441CREATE TABLE stages  (
 442	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 443	cname      	VARCHAR(250) NOT NULL,
 444	description	VARCHAR(550) DEFAULT NULL,
 445	extravalue 	DOUBLE DEFAULT 0,
 446	intaddedby 	BIGINT(20) DEFAULT 0,
 447	dateadded  	DATE NOT NULL,
 448	groupsids  	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1
 449)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 450
 451CREATE TABLE subitems  (
 452	ids                	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 453	cname              	VARCHAR(5000) DEFAULT NULL,
 454	itemsids           	BIGINT(20) UNSIGNED NOT NULL ,
 455	groupsids          	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 456	originalproductsids	BIGINT(20) UNSIGNED DEFAULT NULL,
 457	countvalue         	DOUBLE NOT NULL DEFAULT 0,
 458	quantityvalue      	DOUBLE NOT NULL DEFAULT 0,
 459	measure            	VARCHAR(250) NOT NULL,
 460	linkurl            	VARCHAR(1000) DEFAULT NULL,
 461	description        	VARCHAR(1000) DEFAULT NULL,
 462	internalvalue      	DOUBLE DEFAULT 0,
 463	totalnetvalue      	DOUBLE DEFAULT 0,
 464	totalbrutvalue     	DOUBLE DEFAULT 0,
 465	externalvalue      	DOUBLE DEFAULT 0,
 466	taxpercentvalue    	DOUBLE NOT NULL DEFAULT 0,
 467	datedelivery       	DATE DEFAULT NULL,
 468	dateadded          	DATE NOT NULL,
 469	intaddedby         	BIGINT(20) DEFAULT 0,
 470	invisible          	SMALLINT DEFAULT 0,
 471	reserve1           	VARCHAR(500) DEFAULT NULL,
 472	reserve2           	VARCHAR(500) DEFAULT NULL
 473)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 474
 475CREATE TABLE tablelock  (
 476	ids     	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 477	cname   	VARCHAR(250),
 478	rowid   	BIGINT(20) NOT NULL,
 479	usersids	BIGINT(20) UNSIGNED NOT NULL ,
 480	reserve1	VARCHAR(500) DEFAULT NULL,
 481	reserve2	VARCHAR(500) DEFAULT NULL
 482)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 483
 484CREATE TABLE tax  (
 485	ids       	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 486	cname     	VARCHAR(250),
 487	taxvalue  	DOUBLE DEFAULT 0,
 488	identifier	VARCHAR(250) DEFAULT NULL,
 489	groupsids 	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 490	country   	VARCHAR(50) DEFAULT NULL,
 491	dateadded 	DATE NOT NULL,
 492	intaddedby	BIGINT(20) DEFAULT 0,
 493	invisible 	SMALLINT DEFAULT 0,
 494	reserve1  	VARCHAR(500) DEFAULT NULL,
 495	reserve2  	VARCHAR(500) DEFAULT NULL
 496)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 497
 498CREATE TABLE templates  (
 499	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 500	cname      	VARCHAR(250) NOT NULL,
 501	format     	VARCHAR(55) DEFAULT NULL,
 502	description	VARCHAR(550) DEFAULT NULL,
 503	intsize    	BIGINT(20) DEFAULT 0,
 504	mimetype   	VARCHAR(25) DEFAULT NULL,
 505	filename   	VARCHAR(25) NOT NULL,
 506	intaddedby 	BIGINT(20) DEFAULT 0,
 507	dateadded  	DATE NOT NULL,
 508	groupsids  	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1
 509)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 510
 511CREATE TABLE templatestousers  (
 512	ids         	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 513	cname       	VARCHAR(250) NOT NULL,
 514	usersids    	BIGINT(20) UNSIGNED NOT NULL ,
 515	templatesids	BIGINT(20) UNSIGNED NOT NULL NOT NULL,
 516	groupsids   	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1
 517)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 518
 519CREATE TABLE trashbin  (
 520	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 521	cname      	VARCHAR(500),
 522	rowid      	BIGINT(20) NOT NULL,
 523	description	VARCHAR(2500),
 524	deleteme   	SMALLINT DEFAULT 1,
 525	reserve1   	VARCHAR(500) DEFAULT NULL,
 526	reserve2   	VARCHAR(500) DEFAULT NULL
 527)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 528
 529CREATE TABLE userproperties  (
 530	ids       	BIGINT(20) DEFAULT 1,
 531	cname     	VARCHAR(250) NOT NULL,
 532	value     	VARCHAR(250) NOT NULL,
 533	usersids  	BIGINT(20) UNSIGNED NOT NULL NOT NULL,
 534	dateadded 	DATE NOT NULL,
 535	intaddedby	BIGINT(20) DEFAULT 0,
 536	groupsids 	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 537	invisible 	SMALLINT DEFAULT 0
 538	)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 539
 540CREATE TABLE users  (
 541	ids              	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 542	cname            	VARCHAR(250) NOT NULL,
 543	groupsids        	BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
 544	intdefaultaccount	BIGINT(20) DEFAULT 1,
 545	compsids         	BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
 546	intdefaultstatus 	BIGINT(20) DEFAULT 1,
 547	fullname         	VARCHAR(250) NOT NULL,
 548	password         	VARCHAR(250) NOT NULL,
 549	laf              	VARCHAR(50) DEFAULT NULL,
 550	locale           	VARCHAR(50) DEFAULT NULL,
 551	defcountry       	VARCHAR(50) DEFAULT NULL,
 552	mail             	VARCHAR(50) DEFAULT NULL,
 553	language         	VARCHAR(50) DEFAULT NULL,
 554	inthighestright  	SMALLINT DEFAULT 3,
 555	isenabled        	SMALLINT DEFAULT 1,
 556	isrgrouped       	SMALLINT DEFAULT 0,
 557	isloggedin       	SMALLINT DEFAULT 0,
 558	datelastlog      	DATE DEFAULT NULL,
 559	dateadded        	DATE NOT NULL,
 560	intaddedby       	BIGINT(20) DEFAULT 0,
 561	invisible        	SMALLINT DEFAULT 0,
 562	reserve1         	VARCHAR(500) DEFAULT NULL,
 563	reserve2         	VARCHAR(500) DEFAULT NULL
 564)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 565
 566CREATE TABLE webshops  (
 567	ids                 	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 568	cname               	VARCHAR(250) NOT NULL,
 569	description         	VARCHAR(750) DEFAULT NULL,
 570	groupsids           	BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
 571	dateadded           	DATE NOT NULL,
 572	isrequestcompression	SMALLINT DEFAULT 0,
 573	isauthenticated     	SMALLINT DEFAULT 0,
 574	username            	VARCHAR(50) DEFAULT NULL,
 575	passw               	VARCHAR(50) DEFAULT NULL,
 576	reserve1            	VARCHAR(500) DEFAULT NULL,
 577	intaddedby          	BIGINT(20) DEFAULT 0,
 578	interv               	BIGINT(20) DEFAULT 0,
 579	url                 	VARCHAR(500) DEFAULT NULL,
 580	reserve2            	VARCHAR(500) DEFAULT NULL
 581)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 582
 583CREATE TABLE wscontactsmapping  (
 584	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 585	webshopsids	BIGINT(20) UNSIGNED NOT NULL ,
 586	cname      	VARCHAR(250) NOT NULL,
 587	groupsids  	BIGINT(20) UNSIGNED NOT NULL ,
 588	contactsids	BIGINT(20) UNSIGNED NOT NULL ,
 589	wscontact  	VARCHAR(250) NOT NULL,
 590	dateadded  	DATE DEFAULT NULL,
 591	intaddedby 	BIGINT(20) DEFAULT 0,
 592	invisible  	SMALLINT DEFAULT 0,
 593	reserve1   	VARCHAR(500) DEFAULT NULL,
 594	reserve2   	VARCHAR(500) DEFAULT NULL
 595)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 596
 597CREATE TABLE wsitemsmapping  (
 598	ids        	BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
 599	webshopsids	BIGINT(20) UNSIGNED NOT NULL ,
 600	cname      	VARCHAR(250) NOT NULL,
 601	groupsids  	BIGINT(20) UNSIGNED NOT NULL ,
 602	itemsids   	BIGINT(20) UNSIGNED NOT NULL ,
 603	wsitem     	VARCHAR(250) NOT NULL,
 604	dateadded  	DATE DEFAULT NULL,
 605	intaddedby 	BIGINT(20) DEFAULT 0,
 606	invisible  	SMALLINT DEFAULT 0,
 607	reserve1   	VARCHAR(500) DEFAULT NULL,
 608	reserve2   	VARCHAR(500) DEFAULT NULL
 609)ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 610
 611CREATE UNIQUE INDEX SQL091006084310810
 612	ON groups(cname);
 613
 614CREATE UNIQUE INDEX SQL091006084310820
 615	ON groups(ids);
 616
 617CREATE UNIQUE INDEX SQL091006084311391
 618	ON productgroups(cname, groupsids);
 619
 620CREATE UNIQUE INDEX SQL091006084311390
 621	ON productgroups(ids);
 622
 623CREATE UNIQUE INDEX SQL091006084311800
 624	ON history(ids);
 625
 626CREATE UNIQUE INDEX SQL091006084312110
 627	ON countries(iso);
 628
 629CREATE UNIQUE INDEX SQL091006084312111
 630	ON countries(ids);
 631
 632CREATE UNIQUE INDEX SQL091006084312620
 633	ON globalsettings(cname, groupsids);
 634
 635CREATE UNIQUE INDEX SQL091006084312900
 636	ON tax(ids);
 637
 638CREATE INDEX SQL091006084312890
 639	ON tax(groupsids);
 640
 641CREATE UNIQUE INDEX SQL091006084313452
 642	ON contacts(cnumber, groupsids);
 643
 644CREATE UNIQUE INDEX SQL091006084313451
 645	ON contacts(ids);
 646
 647CREATE INDEX SQL091006084313450
 648	ON contacts(groupsids);
 649
 650CREATE UNIQUE INDEX SQL091006084313971
 651	ON users(cname, groupsids);
 652
 653CREATE UNIQUE INDEX SQL091006084313970
 654	ON users(ids);
 655
 656CREATE INDEX SQL091006084313960
 657	ON users(groupsids);
 658
 659CREATE UNIQUE INDEX SQL091006084314570
 660	ON files(cname);
 661
 662CREATE UNIQUE INDEX SQL091006084314572
 663	ON files(ids);
 664
 665CREATE INDEX SQL091006084314571
 666	ON files(groupsids);
 667
 668CREATE UNIQUE INDEX SQL091006084315174
 669	ON languages(cname, groupsids);
 670
 671CREATE UNIQUE INDEX SQL091006084315171
 672	ON languages(longname);
 673
 674CREATE UNIQUE INDEX SQL091006084315173
 675	ON languages(ids);
 676
 677CREATE INDEX SQL091006084315170
 678	ON languages(groupsids);
 679
 680CREATE INDEX SQL091006084315172
 681	ON languages(filename);
 682
 683CREATE UNIQUE INDEX SQL091006084315882
 684	ON favourites(ids);
 685
 686CREATE INDEX SQL091006084315880
 687	ON favourites(usersids);
 688
 689CREATE INDEX SQL091006084315881
 690	ON favourites(groupsids);
 691
 692CREATE UNIQUE INDEX SQL091006084316451
 693	ON accounts(ids);
 694
 695CREATE INDEX SQL091006084316450
 696	ON accounts(groupsids);
 697
 698CREATE UNIQUE INDEX SQL091006084316862
 699	ON items(cnumber, inttype);
 700
 701CREATE UNIQUE INDEX SQL091006084316861
 702	ON items(ids);
 703
 704CREATE INDEX SQL091006084316850
 705	ON items(groupsids);
 706
 707CREATE INDEX SQL091006084316851
 708	ON items(accountsids);
 709
 710CREATE INDEX SQL091006084316860
 711	ON items(contactsids);
 712
 713CREATE UNIQUE INDEX SQL091006084317902
 714	ON subitems(ids);
 715
 716CREATE INDEX SQL091006084317900
 717	ON subitems(itemsids);
 718
 719CREATE INDEX SQL091006084317901
 720	ON subitems(groupsids);
 721
 722CREATE UNIQUE INDEX SQL091006084318483
 723	ON schedule(ids);
 724
 725CREATE INDEX SQL091006084318480
 726	ON schedule(groupsids);
 727
 728CREATE INDEX SQL091006084318481
 729	ON schedule(usersids);
 730
 731CREATE INDEX SQL091006084318482
 732	ON schedule(itemsids);
 733
 734CREATE UNIQUE INDEX SQL091006084319621
 735	ON products(cnumber, groupsids);
 736
 737CREATE UNIQUE INDEX SQL091006084319620
 738	ON products(ids);
 739
 740CREATE INDEX SQL091006084319610
 741	ON products(taxids);
 742
 743CREATE INDEX SQL091006084319611
 744	ON products(groupsids);
 745
 746CREATE INDEX SQL091006084319612
 747	ON products(productgroupsids);
 748
 749CREATE UNIQUE INDEX SQL091006084320591
 750	ON productlists(ids);
 751
 752CREATE INDEX SQL091006084320590
 753	ON productlists(groupsids);
 754
 755CREATE UNIQUE INDEX SQL091006084321141
 756	ON productlistitems(ids);
 757
 758CREATE INDEX SQL091006084321130
 759	ON productlistitems(groupsids);
 760
 761CREATE INDEX SQL091006084321131
 762	ON productlistitems(productlistsids);
 763
 764CREATE INDEX SQL091006084321140
 765	ON productlistitems(originalproductsids);
 766
 767CREATE INDEX SQL091006084322190
 768	ON userproperties(groupsids);
 769
 770CREATE UNIQUE INDEX SQL091006084322552
 771	ON mails(ids);
 772
 773CREATE INDEX SQL091006084322550
 774	ON mails(groupsids);
 775
 776CREATE INDEX SQL091006084322551
 777	ON mails(usersids);
 778
 779CREATE UNIQUE INDEX SQL091006084323381
 780	ON comps(ids);
 781
 782CREATE INDEX SQL091006084323380
 783	ON comps(groupsids);
 784
 785CREATE UNIQUE INDEX SQL091006084324160
 786	ON expenses(ids);
 787
 788CREATE INDEX SQL091006084324140
 789	ON expenses(groupsids);
 790
 791CREATE INDEX SQL091006084324141
 792	ON expenses(accountsids);
 793
 794CREATE UNIQUE INDEX SQL091006084324810
 795	ON revenues(ids);
 796
 797CREATE INDEX SQL091006084324790
 798	ON revenues(groupsids);
 799
 800CREATE INDEX SQL091006084324800
 801	ON revenues(accountsids);
 802
 803CREATE UNIQUE INDEX SQL091006084325551
 804	ON webshops(cname, groupsids);
 805
 806CREATE UNIQUE INDEX SQL091006084325550
 807	ON webshops(ids);
 808
 809CREATE UNIQUE INDEX SQL091006084326054
 810	ON wscontactsmapping(wscontact, groupsids, webshopsids);
 811
 812CREATE UNIQUE INDEX SQL091006084326053
 813	ON wscontactsmapping(ids);
 814
 815CREATE INDEX SQL091006084326050
 816	ON wscontactsmapping(webshopsids);
 817
 818CREATE INDEX SQL091006084326051
 819	ON wscontactsmapping(groupsids);
 820
 821CREATE INDEX SQL091006084326052
 822	ON wscontactsmapping(contactsids);
 823
 824CREATE UNIQUE INDEX SQL091006084326881
 825	ON wsitemsmapping(wsitem, groupsids, webshopsids);
 826
 827CREATE UNIQUE INDEX SQL091006084326880
 828	ON wsitemsmapping(ids);
 829
 830CREATE INDEX SQL091006084326870
 831	ON wsitemsmapping(webshopsids);
 832
 833CREATE INDEX SQL091006084326871
 834	ON wsitemsmapping(groupsids);
 835
 836CREATE INDEX SQL091006084326872
 837	ON wsitemsmapping(itemsids);
 838
 839CREATE UNIQUE INDEX SQL091006084327910
 840	ON tablelock(ids);
 841
 842CREATE UNIQUE INDEX SQL091006084327911
 843	ON tablelock(cname, rowid);
 844
 845CREATE INDEX SQL091006084327890
 846	ON tablelock(usersids);
 847
 848CREATE UNIQUE INDEX SQL091006084328480
 849	ON itemstoaccounts(ids);
 850
 851CREATE INDEX SQL091006084328460
 852	ON itemstoaccounts(itemsids);
 853
 854CREATE INDEX SQL091006084328461
 855	ON itemstoaccounts(accountsids);
 856
 857CREATE UNIQUE INDEX SQL091006084329120
 858	ON trashbin(ids);
 859
 860CREATE UNIQUE INDEX SQL091006084329671
 861	ON filestocontacts(ids);
 862
 863CREATE INDEX SQL091006084329650
 864	ON filestocontacts(contactsids);
 865
 866CREATE INDEX SQL091006084329651
 867	ON filestocontacts(filename);
 868
 869CREATE INDEX SQL091006084329670
 870	ON filestocontacts(groupsids);
 871
 872CREATE UNIQUE INDEX SQL091006084330492
 873	ON templates(ids);
 874
 875CREATE INDEX SQL091006084330490
 876	ON templates(filename);
 877
 878CREATE INDEX SQL091006084330491
 879	ON templates(groupsids);
 880
 881CREATE UNIQUE INDEX SQL091006084331263
 882	ON filestoitems(ids);
 883
 884CREATE INDEX SQL091006084331260
 885	ON filestoitems(itemsids);
 886
 887CREATE INDEX SQL091006084331261
 888	ON filestoitems(filename);
 889
 890CREATE INDEX SQL091006084331262
 891	ON filestoitems(groupsids);
 892
 893CREATE UNIQUE INDEX SQL091006084332163
 894	ON filestoproducts(ids);
 895
 896CREATE INDEX SQL091006084332160
 897	ON filestoproducts(productsids);
 898
 899CREATE INDEX SQL091006084332161
 900	ON filestoproducts(filename);
 901
 902CREATE INDEX SQL091006084332162
 903	ON filestoproducts(groupsids);
 904
 905CREATE UNIQUE INDEX SQL091006084333560
 906	ON plugins(ids);
 907
 908CREATE INDEX SQL091006084333550
 909	ON plugins(filename);
 910
 911CREATE INDEX SQL091006084333551
 912	ON plugins(groupsids);
 913
 914CREATE UNIQUE INDEX SQL091006084334241
 915	ON pluginstousers(ids);
 916
 917CREATE INDEX SQL091006084334230
 918	ON pluginstousers(pluginsids);
 919
 920CREATE INDEX SQL091006084334240
 921	ON pluginstousers(groupsids);
 922
 923CREATE UNIQUE INDEX SQL091006084334891
 924	ON formatstousers(ids);
 925
 926CREATE INDEX SQL091006084334890
 927	ON formatstousers(usersids);
 928
 929CREATE UNIQUE INDEX SQL091006084335461
 930	ON templatestousers(ids);
 931
 932CREATE INDEX SQL091006084335450
 933	ON templatestousers(usersids);
 934
 935CREATE INDEX SQL091006084335451
 936	ON templatestousers(templatesids);
 937
 938CREATE INDEX SQL091006084335460
 939	ON templatestousers(groupsids);
 940
 941CREATE UNIQUE INDEX SQL091006084336332
 942	ON addresses(ids);
 943
 944CREATE INDEX SQL091006084336330
 945	ON addresses(groupsids);
 946
 947CREATE INDEX SQL091006084336331
 948	ON addresses(contactsids);
 949
 950CREATE UNIQUE INDEX SQL091006084336882
 951	ON reminders(ids);
 952
 953CREATE INDEX SQL091006084336880
 954	ON reminders(itemsids);
 955
 956CREATE INDEX SQL091006084336881
 957	ON reminders(groupsids);
 958
 959CREATE UNIQUE INDEX SQL091006084337581
 960	ON stages(ids);
 961
 962CREATE INDEX SQL091006084337580
 963	ON stages(groupsids);
 964
 965ALTER TABLE contacts
 966	ADD CONSTRAINT CONST3
 967	 UNIQUE (cnumber, groupsids) ;
 968
 969ALTER TABLE countries
 970	ADD CONSTRAINT SQL0910060843121101
 971	 UNIQUE (iso) ;
 972
 973ALTER TABLE files
 974	ADD CONSTRAINT SQL0910060843145701
 975	 UNIQUE (cname) ;
 976
 977ALTER TABLE globalsettings
 978	ADD CONSTRAINT CONST2
 979	 UNIQUE (cname, groupsids) ;
 980
 981ALTER TABLE groups
 982	ADD CONSTRAINT SQL0910060843108101
 983	 UNIQUE (cname) ;
 984
 985ALTER TABLE items
 986	ADD CONSTRAINT CONST7
 987	 UNIQUE (cnumber, inttype) ;
 988
 989ALTER TABLE languages
 990	ADD CONSTRAINT SQL0910060843151711
 991	 UNIQUE (longname) ;
 992
 993ALTER TABLE languages
 994	ADD CONSTRAINT CONST6
 995	 UNIQUE (cname, groupsids) ;
 996
 997ALTER TABLE productgroups
 998	ADD CONSTRAINT CONST1
 999	 UNIQUE (cname, groupsids) ;
1000
1001ALTER TABLE products
1002	ADD CONSTRAINT CONST8
1003	 UNIQUE (cnumber, groupsids) ;
1004
1005ALTER TABLE tablelock
1006	ADD CONSTRAINT ONE_LOCK
1007	 UNIQUE (cname, rowid) ;
1008
1009ALTER TABLE users
1010	ADD CONSTRAINT CONST4
1011	 UNIQUE (cname, groupsids) ;
1012
1013ALTER TABLE webshops
1014	ADD CONSTRAINT CONST9
1015	 UNIQUE (cname, groupsids) ;
1016
1017ALTER TABLE wscontactsmapping
1018	ADD CONSTRAINT CONST10
1019	 UNIQUE (wscontact, groupsids, webshopsids) ;
1020
1021ALTER TABLE wsitemsmapping
1022	ADD CONSTRAINT CONST11
1023	 UNIQUE (wsitem, groupsids, webshopsids) ;
1024
1025ALTER TABLE accounts
1026	ADD CONSTRAINT SQL0910060843164501
1027	FOREIGN KEY(groupsids)
1028	REFERENCES groups(ids);
1029
1030ALTER TABLE addresses
1031	ADD CONSTRAINT SQL0910060843363311
1032	FOREIGN KEY(contactsids)
1033	REFERENCES contacts(ids);
1034
1035ALTER TABLE addresses
1036	ADD CONSTRAINT SQL0910060843363301
1037	FOREIGN KEY(groupsids)
1038	REFERENCES groups(ids);
1039
1040ALTER TABLE comps
1041	ADD CONSTRAINT SQL0910060843233801
1042	FOREIGN KEY(groupsids)
1043	REFERENCES groups(ids);
1044
1045ALTER TABLE contacts
1046	ADD CONSTRAINT SQL0910060843134501
1047	FOREIGN KEY(groupsids)
1048	REFERENCES groups(ids);
1049
1050ALTER TABLE expenses
1051	ADD CONSTRAINT SQL0910060843241411
1052	FOREIGN KEY(accountsids)
1053	REFERENCES accounts(ids);
1054
1055ALTER TABLE expenses
1056	ADD CONSTRAINT SQL0910060843241401
1057	FOREIGN KEY(groupsids)
1058	REFERENCES groups(ids);
1059
1060ALTER TABLE favourites
1061	ADD CONSTRAINT SQL0910060843158811
1062	FOREIGN KEY(groupsids)
1063	REFERENCES groups(ids);
1064
1065ALTER TABLE favourites
1066	ADD CONSTRAINT SQL0910060843158801
1067	FOREIGN KEY(usersids)
1068	REFERENCES users(ids)
1069	ON DELETE CASCADE ;
1070
1071ALTER TABLE files
1072	ADD CONSTRAINT SQL0910060843145711
1073	FOREIGN KEY(groupsids)
1074	REFERENCES groups(ids);
1075
1076ALTER TABLE filestocontacts
1077	ADD CONSTRAINT SQL0910060843296701
1078	FOREIGN KEY(groupsids)
1079	REFERENCES groups(ids);
1080
1081ALTER TABLE filestocontacts
1082	ADD CONSTRAINT SQL0910060843296511
1083	FOREIGN KEY(filename)
1084	REFERENCES files(cname)
1085	ON DELETE CASCADE ;
1086
1087ALTER TABLE filestocontacts
1088	ADD CONSTRAINT SQL0910060843296501
1089	FOREIGN KEY(contactsids)
1090	REFERENCES contacts(ids)
1091	ON DELETE CASCADE ;
1092
1093ALTER TABLE filestoitems
1094	ADD CONSTRAINT SQL0910060843312621
1095	FOREIGN KEY(groupsids)
1096	REFERENCES groups(ids);
1097
1098ALTER TABLE filestoitems
1099	ADD CONSTRAINT SQL0910060843312611
1100	FOREIGN KEY(filename)
1101	REFERENCES files(cname)
1102	ON DELETE CASCADE ;
1103
1104ALTER TABLE filestoitems
1105	ADD CONSTRAINT SQL0910060843312601
1106	FOREIGN KEY(itemsids)
1107	REFERENCES items(ids)
1108	ON DELETE CASCADE ;
1109
1110ALTER TABLE filestoproducts
1111	ADD CONSTRAINT SQL0910060843321621
1112	FOREIGN KEY(groupsids)
1113	REFERENCES groups(ids);
1114
1115ALTER TABLE filestoproducts
1116	ADD CONSTRAINT SQL0910060843321611
1117	FOREIGN KEY(filename)
1118	REFERENCES files(cname)
1119	ON DELETE CASCADE ;
1120
1121ALTER TABLE filestoproducts
1122	ADD CONSTRAINT SQL0910060843321601
1123	FOREIGN KEY(productsids)
1124	REFERENCES products(ids)
1125	ON DELETE CASCADE ;
1126
1127ALTER TABLE formatstousers
1128	ADD CONSTRAINT SQL0910060843348901
1129	FOREIGN KEY(usersids)
1130	REFERENCES users(ids)
1131	ON DELETE CASCADE ;
1132
1133ALTER TABLE items
1134	ADD CONSTRAINT SQL0910060843168601
1135	FOREIGN KEY(contactsids)
1136	REFERENCES contacts(ids)
1137	ON DELETE CASCADE ;
1138
1139ALTER TABLE items
1140	ADD CONSTRAINT SQL0910060843168511
1141	FOREIGN KEY(accountsids)
1142	REFERENCES accounts(ids);
1143
1144ALTER TABLE items
1145	ADD CONSTRAINT SQL0910060843168501
1146	FOREIGN KEY(groupsids)
1147	REFERENCES groups(ids);
1148
1149ALTER TABLE itemstoaccounts
1150	ADD CONSTRAINT SQL0910060843284611
1151	FOREIGN KEY(accountsids)
1152	REFERENCES accounts(ids)
1153	ON DELETE CASCADE ;
1154
1155ALTER TABLE itemstoaccounts
1156	ADD CONSTRAINT SQL0910060843284601
1157	FOREIGN KEY(itemsids)
1158	REFERENCES items(ids)
1159	ON DELETE CASCADE ;
1160
1161ALTER TABLE languages
1162	ADD CONSTRAINT SQL0910060843151721
1163	FOREIGN KEY(filename)
1164	REFERENCES files(cname)
1165	ON DELETE CASCADE ;
1166
1167ALTER TABLE languages
1168	ADD CONSTRAINT SQL0910060843151701
1169	FOREIGN KEY(groupsids)
1170	REFERENCES groups(ids);
1171
1172ALTER TABLE mails
1173	ADD CONSTRAINT SQL0910060843225511
1174	FOREIGN KEY(usersids)
1175	REFERENCES users(ids)
1176	ON DELETE CASCADE ;
1177
1178ALTER TABLE mails
1179	ADD CONSTRAINT SQL0910060843225501
1180	FOREIGN KEY(groupsids)
1181	REFERENCES groups(ids);
1182
1183ALTER TABLE plugins
1184	ADD CONSTRAINT SQL0910060843335511
1185	FOREIGN KEY(groupsids)
1186	REFERENCES groups(ids);
1187
1188ALTER TABLE plugins
1189	ADD CONSTRAINT SQL0910060843335501
1190	FOREIGN KEY(filename)
1191	REFERENCES files(cname)
1192	ON DELETE CASCADE ;
1193
1194ALTER TABLE pluginstousers
1195	ADD CONSTRAINT SQL0910060843342401
1196	FOREIGN KEY(groupsids)
1197	REFERENCES groups(ids);
1198
1199ALTER TABLE pluginstousers
1200	ADD CONSTRAINT SQL0910060843342301
1201	FOREIGN KEY(pluginsids)
1202	REFERENCES plugins(ids)
1203	ON DELETE CASCADE ;
1204
1205ALTER TABLE productlistitems
1206	ADD CONSTRAINT SQL0910060843211401
1207	FOREIGN KEY(originalproductsids)
1208	REFERENCES products(ids)
1209	ON DELETE CASCADE ;
1210
1211ALTER TABLE productlistitems
1212	ADD CONSTRAINT SQL0910060843211311
1213	FOREIGN KEY(productlistsids)
1214	REFERENCES productlists(ids)
1215	ON DELETE CASCADE ;
1216
1217ALTER TABLE productlistitems
1218	ADD CONSTRAINT SQL0910060843211301
1219	FOREIGN KEY(groupsids)
1220	REFERENCES groups(ids);
1221
1222ALTER TABLE productlists
1223	ADD CONSTRAINT SQL0910060843205901
1224	FOREIGN KEY(groupsids)
1225	REFERENCES groups(ids);
1226
1227ALTER TABLE products
1228	ADD CONSTRAINT SQL0910060843196121
1229	FOREIGN KEY(productgroupsids)
1230	REFERENCES productsgroups(ids);
1231
1232ALTER TABLE products
1233	ADD CONSTRAINT SQL0910060843196111
1234	FOREIGN KEY(groupsids)
1235	REFERENCES groups(ids);
1236
1237ALTER TABLE products
1238	ADD CONSTRAINT SQL0910060843196101
1239	FOREIGN KEY(taxids)
1240	REFERENCES tax(ids);
1241
1242ALTER TABLE reminders
1243	ADD CONSTRAINT SQL0910060843368811
1244	FOREIGN KEY(groupsids)
1245	REFERENCES groups(ids);
1246
1247ALTER TABLE reminders
1248	ADD CONSTRAINT SQL0910060843368801
1249	FOREIGN KEY(itemsids)
1250	REFERENCES items(ids)
1251	ON DELETE CASCADE ;
1252
1253ALTER TABLE revenues
1254	ADD CONSTRAINT SQL0910060843248001
1255	FOREIGN KEY(accountsids)
1256	REFERENCES accounts(ids);
1257
1258ALTER TABLE revenues
1259	ADD CONSTRAINT SQL0910060843247901
1260	FOREIGN KEY(groupsids)
1261	REFERENCES groups(ids);
1262
1263ALTER TABLE schedule
1264	ADD CONSTRAINT SQL0910060843184821
1265	FOREIGN KEY(itemsids)
1266	REFERENCES items(ids)
1267	ON DELETE CASCADE ;
1268
1269ALTER TABLE schedule
1270	ADD CONSTRAINT SQL0910060843184811
1271	FOREIGN KEY(usersids)
1272	REFERENCES users(ids)
1273	ON DELETE CASCADE ;
1274
1275ALTER TABLE schedule
1276	ADD CONSTRAINT SQL0910060843184801
1277	FOREIGN KEY(groupsids)
1278	REFERENCES groups(ids);
1279
1280ALTER TABLE stages
1281	ADD CONSTRAINT SQL0910060843375801
1282	FOREIGN KEY(groupsids)
1283	REFERENCES groups(ids);
1284
1285ALTER TABLE subitems
1286	ADD CONSTRAINT SQL0910060843179011
1287	FOREIGN KEY(groupsids)
1288	REFERENCES groups(ids);
1289
1290ALTER TABLE subitems
1291	ADD CONSTRAINT SQL0910060843179001
1292	FOREIGN KEY(itemsids)
1293	REFERENCES items(ids)
1294	ON DELETE CASCADE ;
1295
1296ALTER TABLE tablelock
1297	ADD CONSTRAINT SQL0910060843278901
1298	FOREIGN KEY(usersids)
1299	REFERENCES users(ids)
1300	ON DELETE CASCADE ;
1301
1302ALTER TABLE tax
1303	ADD CONSTRAINT SQL0910060843128901
1304	FOREIGN KEY(groupsids)
1305	REFERENCES groups(ids);
1306
1307ALTER TABLE templates
1308	ADD CONSTRAINT SQL0910060843304911
1309	FOREIGN KEY(groupsids)
1310	REFERENCES groups(ids);
1311
1312ALTER TABLE templates
1313	ADD CONSTRAINT SQL0910060843304901
1314	FOREIGN KEY(filename)
1315	REFERENCES files(cname)
1316	ON DELETE CASCADE ;
1317
1318ALTER TABLE templatestousers
1319	ADD CONSTRAINT SQL0910060843354601
1320	FOREIGN KEY(groupsids)
1321	REFERENCES groups(ids);
1322
1323ALTER TABLE templatestousers
1324	ADD CONSTRAINT SQL0910060843354511
1325	FOREIGN KEY(templatesids)
1326	REFERENCES templates(ids)
1327	ON DELETE CASCADE ;
1328
1329ALTER TABLE templatestousers
1330	ADD CONSTRAINT SQL0910060843354501
1331	FOREIGN KEY(usersids)
1332	REFERENCES users(ids)
1333	ON DELETE CASCADE ;
1334
1335ALTER TABLE userproperties
1336	ADD CONSTRAINT SQL0910060843221901
1337	FOREIGN KEY(groupsids)
1338	REFERENCES groups(ids);
1339
1340ALTER TABLE users
1341	ADD CONSTRAINT SQL0910060843139601
1342	FOREIGN KEY(groupsids)
1343	REFERENCES groups(ids);
1344
1345ALTER TABLE wscontactsmapping
1346	ADD CONSTRAINT SQL0910060843260521
1347	FOREIGN KEY(contactsids)
1348	REFERENCES contacts(ids)
1349	ON DELETE CASCADE ;
1350
1351ALTER TABLE wscontactsmapping
1352	ADD CONSTRAINT SQL0910060843260511
1353	FOREIGN KEY(groupsids)
1354	REFERENCES groups(ids)
1355	ON DELETE CASCADE ;
1356
1357ALTER TABLE wscontactsmapping
1358	ADD CONSTRAINT SQL0910060843260501
1359	FOREIGN KEY(webshopsids)
1360	REFERENCES webshops(ids)
1361	ON DELETE CASCADE ;
1362
1363ALTER TABLE wsitemsmapping
1364	ADD CONSTRAINT SQL0910060843268721
1365	FOREIGN KEY(itemsids)
1366	REFERENCES contacts(ids)
1367	ON DELETE CASCADE ;
1368
1369ALTER TABLE wsitemsmapping
1370	ADD CONSTRAINT SQL0910060843268711
1371	FOREIGN KEY(groupsids)
1372	REFERENCES groups(ids)
1373	ON DELETE CASCADE ;
1374
1375ALTER TABLE wsitemsmapping
1376	ADD CONSTRAINT SQL0910060843268701
1377	FOREIGN KEY(webshopsids)
1378	REFERENCES webshops(ids)
1379	ON DELETE CASCADE ;
1380
1381
1382
1383DELIMITER %
1384
1385DROP TRIGGER IF EXISTS contacts_INDEXER1
1386%
1387CREATE TRIGGER contacts_INDEXER1
1388        AFTER INSERT ON contacts
1389
1390        FOR EACH ROW BEGIN
1391        INSERT INTO searchindex (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids, 'contacts',NEW.ids,NEW.cnumber||' '||NEW.taxnumber||' '||NEW.title||' '||NEW.country||' '|| NEW.prename||' '|| NEW.cname||' '|| NEW.street||' '||NEW.zip||' '|| NEW.city ||' '||NEW.mainphone||' '||NEW.fax||' '||NEW.mobilephone||' '||NEW.workphone||' '||NEW.mailaddress||' '||NEW.company||' '|| NEW.department||' '||NEW.website||' '||NEW.notes);
1392END;
1393        %
1394
1395DROP TRIGGER IF EXISTS contacts_INDEXER2
1396%
1397CREATE TRIGGER contacts_INDEXER2
1398        AFTER UPDATE ON contacts
1399
1400        FOR EACH ROW BEGIN
1401        DELETE FROM searchindex WHERE dbidentity = 'contacts' AND  rowid = NEW.ids;
1402        INSERT INTO searchindex  (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids,'contacts',NEW.ids,NEW.cnumber||' '||NEW.taxnumber||' '||NEW.title||' '||NEW.country||' '|| NEW.prename||' '|| NEW.cname||' '|| NEW.street||' '||NEW.zip||' '|| NEW.city ||' '||NEW.mainphone||' '||NEW.fax||' '||NEW.mobilephone||' '||NEW.workphone||' '||NEW.mailaddress||' '||NEW.company||' '|| NEW.department||' '||NEW.website||' '||NEW.notes);
1403        IF NEW.invisible != '0' THEN            
1404          INSERT INTO trashbin (deleteme, cname, rowid, description) VALUES (NEW.invisible,'contacts',NEW.ids,NEW.cnumber||' ('|| NEW.cname||')');                    
1405        ELSE
1406          DELETE FROM trashbin WHERE cname = 'contacts' AND rowid = NEW.ids; 
1407        END IF;
1408END;
1409%
1410
1411DROP TRIGGER IF EXISTS contacts_INDEXER4
1412%
1413CREATE TRIGGER contacts_INDEXER4
1414        AFTER DELETE ON contacts
1415
1416        FOR EACH ROW BEGIN
1417        DELETE FROM searchindex WHERE dbidentity = 'contacts' AND  rowid = OLD.ids;
1418        DELETE FROM trashbin WHERE cname = 'contacts' AND  rowid = OLD.ids;
1419END;
1420%
1421
1422DROP TRIGGER IF EXISTS expenses_INDEXER1
1423%
1424CREATE TRIGGER expenses_INDEXER1
1425        AFTER INSERT ON expenses
1426
1427        FOR EACH ROW BEGIN
1428        INSERT INTO searchindex  (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids,'expenses',NEW.ids,NEW.cname||' '||NEW.dateadded);
1429END;
1430        %
1431
1432DROP TRIGGER IF EXISTS expenses_INDEXER2
1433%        
1434CREATE TRIGGER expenses_INDEXER2
1435        AFTER UPDATE ON expenses
1436
1437        FOR EACH ROW BEGIN
1438        DELETE FROM searchindex WHERE dbidentity = 'expenses' AND  rowid = NEW.ids;
1439        INSERT INTO searchindex  (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids,'expenses',NEW.ids,NEW.cname||' '||NEW.dateadded);
1440        IF NEW.invisible != '0' THEN            
1441          INSERT INTO trashbin (deleteme, cname, rowid, description) VALUES (NEW.invisible,'expenses',NEW.ids,NEW.cname);          
1442        ELSE
1443          DELETE FROM trashbin WHERE cname = 'expenses' AND rowid = NEW.ids; 
1444        END IF;
1445END;
1446%
1447
1448DROP TRIGGER IF EXISTS expenses_INDEXER4
1449%
1450CREATE TRIGGER expenses_INDEXER4
1451        AFTER DELETE ON expenses
1452
1453        FOR EACH ROW BEGIN
1454        DELETE FROM searchindex WHERE dbidentity = 'expenses' AND  rowid = OLD.ids;
1455        DELETE FROM trashbin WHERE cname = 'expenses' AND  rowid = OLD.ids;
1456END;
1457%
1458
1459DROP TRIGGER IF EXISTS filestocontacts_INDEXER1
1460%
1461CREATE TRIGGER filestocontacts_INDEXER1
1462        AFTER INSERT ON filestocontacts
1463
1464        FOR EACH ROW BEGIN
1465        INSERT INTO searchindex (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids,'filestocontacts',NEW.ids,NEW.cname||' '||NEW.description||' '||NEW.filename);
1466END;
1467        %
1468
1469DROP TRIGGER IF EXISTS filestocontacts_INDEXER2
1470%        
1471CREATE TRIGGER filestocontacts_INDEXER2
1472        AFTER UPDATE ON filestocontacts
1473
1474        FOR EACH ROW BEGIN
1475  DELETE FROM searchindex WHERE dbidentity = 'filestocontacts' AND  rowid = NEW.ids;
1476        INSERT INTO searchindex  (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids,'filestocontacts',NEW.ids,NEW.cname||' '||NEW.description||' '||NEW.filename);
1477END;
1478        %
1479
1480DROP TRIGGER IF EXISTS filestocontacts_INDEXER4
1481%
1482CREATE TRIGGER filestocontacts_INDEXER4
1483        AFTER DELETE ON filestocontacts
1484
1485        FOR EACH ROW BEGIN
1486        DELETE FROM searchindex WHERE dbidentity = 'filestocontacts' AND  rowid = OLD.ids;
1487
1488        END;
1489        %
1490
1491DROP TRIGGER IF EXISTS groups_INDEXER1
1492%        
1493CREATE TRIGGER groups_INDEXER1
1494        AFTER INSERT ON groups
1495
1496        FOR EACH ROW BEGIN
1497        INSERT INTO searchindex  (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids,'groups',NEW.ids,NEW.cname||' '||NEW.description||' '||NEW.dateadded);
1498END;
1499        %
1500        
1501DROP TRIGGER IF EXISTS groups_INDEXER2
1502%  
1503CREATE TRIGGER groups_INDEXER2
1504        AFTER UPDATE ON groups
1505
1506        FOR EACH ROW BEGIN
1507        DELETE FROM searchindex WHERE dbidentity = 'groups' AND  rowid = NEW.ids;
1508        INSERT INTO searchindex  (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids,'groups',NEW.ids,NEW.cname||' '||NEW.description||' '||NEW.dateadded);
1509END;
1510%
1511
1512DROP TRIGGER IF EXISTS groups_INDEXER4
1513%  
1514CREATE TRIGGER groups_INDEXER4
1515        AFTER DELETE ON groups
1516
1517        FOR EACH ROW BEGIN
1518        DELETE FROM searchindex WHERE dbidentity = 'groups' AND  rowid = OLD.ids;
1519END;
1520        %
1521
1522DROP TRIGGER IF EXISTS items_INDEXER1
1523%          
1524CREATE TRIGGER items_INDEXER1
1525        AFTER INSERT ON items
1526
1527        FOR EACH ROW BEGIN
1528        INSERT INTO searchindex  (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids,'items',NEW.ids,NEW.cname||' '||NEW.dateadded);
1529END;
1530        %
1531        
1532DROP TRIGGER IF EXISTS items_INDEXER2
1533% 
1534CREATE TRIGGER items_INDEXER2
1535        AFTER UPDATE ON items
1536
1537        FOR EACH ROW BEGIN
1538        DELETE FROM searchindex WHERE dbidentity = 'items' AND  rowid = NEW.ids;
1539        INSERT INTO searchindex  (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids,'items',NEW.ids,NEW.cname||' '||NEW.dateadded);
1540        IF NEW.invisible != '0' THEN            
1541          INSERT INTO trashbin (deleteme, cname, rowid, description) VALUES (NEW.invisible,'items',NEW.ids,NEW.cname);          
1542        ELSE
1543          DELETE FROM trashbin WHERE cname = 'items' AND rowid = NEW.ids; 
1544        END IF;
1545END;
1546%
1547
1548DROP TRIGGER IF EXISTS items_INDEXER4
1549% 
1550CREATE TRIGGER items_INDEXER4
1551        AFTER DELETE ON items
1552
1553        FOR EACH ROW BEGIN
1554        DELETE FROM searchindex WHERE dbidentity = 'items' AND  rowid = OLD.ids;
1555        DELETE FROM trashbin WHERE cname = 'items' AND  rowid = OLD.ids;
1556END;
1557        %
1558
1559DROP TRIGGER IF EXISTS products_INDEXER1
1560% 
1561CREATE TRIGGER products_INDEXER1
1562        AFTER INSERT ON products
1563
1564        FOR EACH ROW BEGIN
1565        INSERT INTO searchindex  (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids,'products',NEW.ids,NEW.cname||' '||NEW.cnumber||' '||NEW.description||' '||NEW.dateadded);
1566END;
1567        %
1568
1569DROP TRIGGER IF EXISTS products_INDEXER2
1570%         
1571CREATE TRIGGER products_INDEXER2
1572        AFTER UPDATE ON products
1573
1574        FOR EACH ROW BEGIN
1575        DELETE FROM searchindex WHERE dbidentity = 'products' AND  rowid = NEW.ids;
1576        INSERT INTO searchindex  (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids,'products',NEW.ids,NEW.cname||' '||NEW.cnumber||' '||NEW.description||' '||NEW.dateadded);
1577        IF NEW.invisible != '0' THEN            
1578          INSERT INTO trashbin (deleteme, cname, rowid, description) VALUES (NEW.invisible, 'products',NEW.ids,NEW.cnumber||' ('|| NEW.cname||')');          
1579        ELSE
1580          DELETE FROM trashbin WHERE cname = 'products' AND rowid = NEW.ids; 
1581        END IF;
1582END;
1583%
1584
1585DROP TRIGGER IF EXISTS products_INDEXER4
1586% 
1587CREATE TRIGGER products_INDEXER4
1588        AFTER DELETE ON products
1589
1590        FOR EACH ROW BEGIN
1591        DELETE FROM searchindex WHERE dbidentity = 'products' AND  rowid = OLD.ids;
1592        DELETE FROM trashbin WHERE cname = 'products' AND  rowid = OLD.ids;
1593END;
1594        %
1595
1596DROP TRIGGER IF EXISTS revenues_INDEXER1
1597% 
1598CREATE TRIGGER revenues_INDEXER1
1599        AFTER INSERT ON revenues
1600
1601        FOR EACH ROW BEGIN
1602        INSERT INTO searchindex  (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids,'revenues',NEW.ids,NEW.cname||' '||NEW.dateadded);
1603END;
1604        %
1605
1606DROP TRIGGER IF EXISTS revenues_INDEXER2
1607%         
1608CREATE TRIGGER revenues_INDEXER2
1609        AFTER UPDATE ON revenues
1610
1611        FOR EACH ROW BEGIN
1612        DELETE FROM searchindex WHERE dbidentity = 'revenues' AND  rowid = NEW.ids;
1613        INSERT INTO searchindex  (groupsids, dbidentity, rowid, text) VALUES (NEW.groupsids,'revenues',NEW.ids,NEW.cname||' '||NEW.dateadded);

Large files files are truncated, but you can click here to view the full file