module_index_act_mysql_setup.go 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329
  1. package modules
  2. import (
  3. "os"
  4. "strconv"
  5. "golang-fave/engine/sqlw"
  6. "golang-fave/engine/utils"
  7. "golang-fave/engine/wrapper"
  8. )
  9. func (this *Modules) RegisterAction_IndexMysqlSetup() *Action {
  10. return this.newAction(AInfo{
  11. Mount: "index-mysql-setup",
  12. }, func(wrap *wrapper.Wrapper) {
  13. pf_host := utils.Trim(wrap.R.FormValue("host"))
  14. pf_port := utils.Trim(wrap.R.FormValue("port"))
  15. pf_name := utils.Trim(wrap.R.FormValue("name"))
  16. pf_user := utils.Trim(wrap.R.FormValue("user"))
  17. pf_password := utils.Trim(wrap.R.FormValue("password"))
  18. if pf_host == "" {
  19. wrap.MsgError(`Please specify host for MySQL connection`)
  20. return
  21. }
  22. if pf_port == "" {
  23. wrap.MsgError(`Please specify host port for MySQL connection`)
  24. return
  25. }
  26. if _, err := strconv.Atoi(pf_port); err != nil {
  27. wrap.MsgError(`MySQL host port must be integer number`)
  28. return
  29. }
  30. if pf_name == "" {
  31. wrap.MsgError(`Please specify MySQL database name`)
  32. return
  33. }
  34. if pf_user == "" {
  35. wrap.MsgError(`Please specify MySQL user`)
  36. return
  37. }
  38. // Security, check if still need to run this action
  39. if wrap.ConfMysqlExists {
  40. wrap.MsgError(`CMS is already configured`)
  41. return
  42. }
  43. // Try connect to mysql
  44. db, err := sqlw.Open("mysql", pf_user+":"+pf_password+"@tcp("+pf_host+":"+pf_port+")/"+pf_name)
  45. if err != nil {
  46. wrap.MsgError(err.Error())
  47. return
  48. }
  49. defer db.Close()
  50. err = db.Ping(wrap.R.Context())
  51. if err != nil {
  52. wrap.MsgError(err.Error())
  53. return
  54. }
  55. // Start transaction
  56. tx, err := db.Begin(wrap.R.Context())
  57. if err != nil {
  58. wrap.MsgError(err.Error())
  59. return
  60. }
  61. // Table: fave_blog_cats
  62. if _, err = tx.Exec(
  63. wrap.R.Context(),
  64. `CREATE TABLE fave_blog_cats (
  65. id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
  66. user int(11) NOT NULL COMMENT 'User id',
  67. name varchar(255) NOT NULL COMMENT 'Category name',
  68. alias varchar(255) NOT NULL COMMENT 'Category alias',
  69. lft int(11) NOT NULL COMMENT 'For nested set model',
  70. rgt int(11) NOT NULL COMMENT 'For nested set model',
  71. PRIMARY KEY (id)
  72. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  73. ); err != nil {
  74. tx.Rollback()
  75. wrap.MsgError(err.Error())
  76. return
  77. }
  78. // Table: fave_blog_cat_post_rel
  79. if _, err = tx.Exec(
  80. wrap.R.Context(),
  81. `CREATE TABLE fave_blog_cat_post_rel (
  82. post_id int(11) NOT NULL COMMENT 'Post id',
  83. category_id int(11) NOT NULL COMMENT 'Category id'
  84. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  85. ); err != nil {
  86. tx.Rollback()
  87. wrap.MsgError(err.Error())
  88. return
  89. }
  90. // Table: fave_blog_posts
  91. if _, err = tx.Exec(
  92. wrap.R.Context(),
  93. `CREATE TABLE fave_blog_posts (
  94. id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
  95. user int(11) NOT NULL COMMENT 'User id',
  96. name varchar(255) NOT NULL COMMENT 'Post name',
  97. alias varchar(255) NOT NULL COMMENT 'Post alias',
  98. category int(11) NOT NULL,
  99. briefly text NOT NULL COMMENT 'Post brief content',
  100. content text NOT NULL COMMENT 'Post content',
  101. datetime datetime NOT NULL COMMENT 'Creation date/time',
  102. active int(1) NOT NULL COMMENT 'Is active post or not',
  103. PRIMARY KEY (id)
  104. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  105. ); err != nil {
  106. tx.Rollback()
  107. wrap.MsgError(err.Error())
  108. return
  109. }
  110. // Table: fave_notify_mail
  111. if _, err = tx.Exec(
  112. wrap.R.Context(),
  113. `CREATE TABLE fave_notify_mail (
  114. id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
  115. email varchar(255) NOT NULL COMMENT 'Email address',
  116. subject varchar(800) NOT NULL COMMENT 'Email subject',
  117. message text NOT NULL COMMENT 'Email body',
  118. error text NOT NULL COMMENT 'Send error message',
  119. datetime datetime NOT NULL COMMENT 'Creation date/time',
  120. status int(1) NOT NULL COMMENT 'Sending status',
  121. PRIMARY KEY (id)
  122. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  123. ); err != nil {
  124. tx.Rollback()
  125. wrap.MsgError(err.Error())
  126. return
  127. }
  128. // Table: fave_pages
  129. if _, err = tx.Exec(
  130. wrap.R.Context(),
  131. `CREATE TABLE fave_pages (
  132. id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
  133. user int(11) NOT NULL COMMENT 'User id',
  134. template varchar(255) NOT NULL DEFAULT 'page' COMMENT 'Template',
  135. name varchar(255) NOT NULL COMMENT 'Page name',
  136. alias varchar(255) NOT NULL COMMENT 'Page url part',
  137. content text NOT NULL COMMENT 'Page content',
  138. meta_title varchar(255) NOT NULL DEFAULT '' COMMENT 'Page meta title',
  139. meta_keywords varchar(255) NOT NULL DEFAULT '' COMMENT 'Page meta keywords',
  140. meta_description varchar(510) NOT NULL DEFAULT '' COMMENT 'Page meta description',
  141. datetime datetime NOT NULL COMMENT 'Creation date/time',
  142. active int(1) NOT NULL COMMENT 'Is active page or not',
  143. PRIMARY KEY (id)
  144. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  145. ); err != nil {
  146. tx.Rollback()
  147. wrap.MsgError(err.Error())
  148. return
  149. }
  150. // Table: fave_settings
  151. if _, err = tx.Exec(
  152. wrap.R.Context(),
  153. `CREATE TABLE fave_settings (
  154. name varchar(255) NOT NULL COMMENT 'Setting name',
  155. value text NOT NULL COMMENT 'Setting value'
  156. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  157. ); err != nil {
  158. tx.Rollback()
  159. wrap.MsgError(err.Error())
  160. return
  161. }
  162. // Table: fave_shop_cat_product_rel
  163. if _, err = tx.Exec(
  164. wrap.R.Context(),
  165. `CREATE TABLE fave_shop_cat_product_rel (
  166. product_id int(11) NOT NULL COMMENT 'Product id',
  167. category_id int(11) NOT NULL COMMENT 'Category id'
  168. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  169. ); err != nil {
  170. tx.Rollback()
  171. wrap.MsgError(err.Error())
  172. return
  173. }
  174. // Table: fave_shop_cats
  175. if _, err = tx.Exec(
  176. wrap.R.Context(),
  177. `CREATE TABLE fave_shop_cats (
  178. id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
  179. user int(11) NOT NULL COMMENT 'User id',
  180. name varchar(255) NOT NULL COMMENT 'Category name',
  181. alias varchar(255) NOT NULL COMMENT 'Category alias',
  182. lft int(11) NOT NULL COMMENT 'For nested set model',
  183. rgt int(11) NOT NULL COMMENT 'For nested set model',
  184. PRIMARY KEY (id)
  185. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  186. ); err != nil {
  187. tx.Rollback()
  188. wrap.MsgError(err.Error())
  189. return
  190. }
  191. // Table: fave_shop_currencies
  192. if _, err = tx.Exec(
  193. wrap.R.Context(),
  194. `CREATE TABLE fave_shop_currencies (
  195. id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
  196. name varchar(255) NOT NULL COMMENT 'Currency name',
  197. coefficient float(8,4) NOT NULL DEFAULT '1.0000' COMMENT 'Currency coefficient',
  198. code varchar(10) NOT NULL COMMENT 'Currency code',
  199. symbol varchar(5) NOT NULL COMMENT 'Currency symbol',
  200. PRIMARY KEY (id)
  201. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  202. ); err != nil {
  203. tx.Rollback()
  204. wrap.MsgError(err.Error())
  205. return
  206. }
  207. // Table: fave_shop_filter_product_values
  208. if _, err = tx.Exec(
  209. wrap.R.Context(),
  210. `CREATE TABLE fave_shop_filter_product_values (
  211. product_id int(11) NOT NULL COMMENT 'Product id',
  212. filter_value_id int(11) NOT NULL COMMENT 'Filter value id'
  213. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  214. ); err != nil {
  215. tx.Rollback()
  216. wrap.MsgError(err.Error())
  217. return
  218. }
  219. // Table: fave_shop_filters
  220. if _, err = tx.Exec(
  221. wrap.R.Context(),
  222. `CREATE TABLE fave_shop_filters (
  223. id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
  224. name varchar(255) NOT NULL COMMENT 'Filter name in CP',
  225. filter varchar(255) NOT NULL COMMENT 'Filter name in site',
  226. PRIMARY KEY (id)
  227. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  228. ); err != nil {
  229. tx.Rollback()
  230. wrap.MsgError(err.Error())
  231. return
  232. }
  233. // Table: fave_shop_filters_values
  234. if _, err = tx.Exec(
  235. wrap.R.Context(),
  236. `CREATE TABLE fave_shop_filters_values (
  237. id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
  238. filter_id int(11) NOT NULL COMMENT 'Filter id',
  239. name varchar(255) NOT NULL COMMENT 'Value name',
  240. PRIMARY KEY (id)
  241. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  242. ); err != nil {
  243. tx.Rollback()
  244. wrap.MsgError(err.Error())
  245. return
  246. }
  247. // Table: fave_shop_order_products
  248. if _, err = tx.Exec(
  249. wrap.R.Context(),
  250. `CREATE TABLE fave_shop_order_products (
  251. id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
  252. order_id int(11) NOT NULL COMMENT 'Order ID',
  253. product_id int(11) NOT NULL COMMENT 'Product ID',
  254. price float(8,2) NOT NULL COMMENT 'Product price',
  255. quantity int(11) NOT NULL COMMENT 'Quantity',
  256. PRIMARY KEY (id)
  257. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  258. ); err != nil {
  259. tx.Rollback()
  260. wrap.MsgError(err.Error())
  261. return
  262. }
  263. // Table: fave_shop_orders
  264. if _, err = tx.Exec(
  265. wrap.R.Context(),
  266. `CREATE TABLE fave_shop_orders (
  267. id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
  268. create_datetime datetime NOT NULL COMMENT 'Create date/time',
  269. update_datetime datetime NOT NULL COMMENT 'Update date/time',
  270. currency_id int(11) NOT NULL COMMENT 'Currency ID',
  271. currency_name varchar(255) NOT NULL COMMENT 'Currency name',
  272. currency_coefficient float(8,4) NOT NULL DEFAULT '1.0000' COMMENT 'Currency coefficient',
  273. currency_code varchar(10) NOT NULL COMMENT 'Currency code',
  274. currency_symbol varchar(5) NOT NULL COMMENT 'Currency symbol',
  275. client_last_name varchar(64) NOT NULL COMMENT 'Client last name',
  276. client_first_name varchar(64) NOT NULL COMMENT 'Client first name',
  277. client_middle_name varchar(64) NOT NULL DEFAULT '' COMMENT 'Client middle name',
  278. client_phone varchar(20) NOT NULL DEFAULT '' COMMENT 'Client phone',
  279. client_email varchar(64) NOT NULL COMMENT 'Client email',
  280. client_delivery_comment text NOT NULL COMMENT 'Client delivery comment',
  281. client_order_comment text NOT NULL COMMENT 'Client order comment',
  282. status int(1) NOT NULL COMMENT 'new/confirmed/inprogress/canceled/completed',
  283. PRIMARY KEY (id)
  284. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  285. ); err != nil {
  286. tx.Rollback()
  287. wrap.MsgError(err.Error())
  288. return
  289. }
  290. // Table: fave_shop_product_images
  291. if _, err = tx.Exec(
  292. wrap.R.Context(),
  293. `CREATE TABLE fave_shop_product_images (
  294. id int(11) NOT NULL AUTO_INCREMENT,
  295. product_id int(11) NOT NULL,
  296. filename varchar(255) NOT NULL,
  297. ord int(11) NOT NULL DEFAULT '0',
  298. PRIMARY KEY (id)
  299. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  300. ); err != nil {
  301. tx.Rollback()
  302. wrap.MsgError(err.Error())
  303. return
  304. }
  305. // Table: fave_shop_products
  306. if _, err = tx.Exec(
  307. wrap.R.Context(),
  308. `CREATE TABLE fave_shop_products (
  309. id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
  310. parent_id int(11) DEFAULT NULL,
  311. user int(11) NOT NULL COMMENT 'User id',
  312. currency int(11) NOT NULL COMMENT 'Currency id',
  313. price float(8,2) NOT NULL COMMENT 'Product price',
  314. price_old float(8,2) NOT NULL DEFAULT '0.00',
  315. price_promo float(8,2) NOT NULL DEFAULT '0.00',
  316. gname varchar(255) NOT NULL,
  317. name varchar(255) NOT NULL COMMENT 'Product name',
  318. alias varchar(255) NOT NULL COMMENT 'Product alias',
  319. vendor varchar(255) NOT NULL,
  320. quantity int(11) NOT NULL,
  321. category int(11) NOT NULL,
  322. briefly text NOT NULL COMMENT 'Product brief content',
  323. content text NOT NULL COMMENT 'Product content',
  324. datetime datetime NOT NULL COMMENT 'Creation date/time',
  325. active int(1) NOT NULL COMMENT 'Is active product or not',
  326. custom1 varchar(2048) NOT NULL DEFAULT '',
  327. custom2 varchar(2048) NOT NULL DEFAULT '',
  328. PRIMARY KEY (id)
  329. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  330. ); err != nil {
  331. tx.Rollback()
  332. wrap.MsgError(err.Error())
  333. return
  334. }
  335. // Table: fave_users
  336. if _, err = tx.Exec(
  337. wrap.R.Context(),
  338. `CREATE TABLE fave_users (
  339. id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
  340. first_name varchar(64) NOT NULL DEFAULT '' COMMENT 'User first name',
  341. last_name varchar(64) NOT NULL DEFAULT '' COMMENT 'User last name',
  342. email varchar(64) NOT NULL COMMENT 'User email',
  343. password varchar(32) NOT NULL COMMENT 'User password (MD5)',
  344. admin int(1) NOT NULL COMMENT 'Is admin user or not',
  345. active int(1) NOT NULL COMMENT 'Is active user or not',
  346. PRIMARY KEY (id)
  347. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
  348. ); err != nil {
  349. tx.Rollback()
  350. wrap.MsgError(err.Error())
  351. return
  352. }
  353. // Demo datas
  354. if _, err = tx.Exec(
  355. wrap.R.Context(),
  356. `INSERT INTO fave_blog_cats (id, user, name, alias, lft, rgt)
  357. VALUES
  358. (1, 1, 'ROOT', 'ROOT', 1, 24),
  359. (2, 1, 'Health and food', 'health-and-food', 2, 15),
  360. (3, 1, 'News', 'news', 16, 21),
  361. (4, 1, 'Hobby', 'hobby', 22, 23),
  362. (5, 1, 'Juices', 'juices', 3, 8),
  363. (6, 1, 'Nutrition', 'nutrition', 9, 14),
  364. (7, 1, 'Natural', 'natural', 4, 5),
  365. (8, 1, 'For kids', 'for-kids', 6, 7),
  366. (9, 1, 'For all', 'for-all', 10, 11),
  367. (10, 1, 'For athletes', 'for-athletes', 12, 13),
  368. (11, 1, 'Computers and technology', 'computers-and-technology', 17, 18),
  369. (12, 1, 'Film industry', 'film-industry', 19, 20);`,
  370. ); err != nil {
  371. tx.Rollback()
  372. wrap.MsgError(err.Error())
  373. return
  374. }
  375. if _, err = tx.Exec(
  376. wrap.R.Context(),
  377. `INSERT INTO fave_blog_cat_post_rel (post_id, category_id) VALUES (1, 9), (2, 12), (3, 8);`,
  378. ); err != nil {
  379. tx.Rollback()
  380. wrap.MsgError(err.Error())
  381. return
  382. }
  383. if _, err = tx.Exec(
  384. wrap.R.Context(),
  385. `INSERT INTO fave_blog_posts SET
  386. id = ?,
  387. user = ?,
  388. name = ?,
  389. alias = ?,
  390. category = ?,
  391. briefly = ?,
  392. content = ?,
  393. datetime = ?,
  394. active = ?
  395. ;`,
  396. 1,
  397. 1,
  398. "Why should we eat wholesome food?",
  399. "why-should-we-eat-wholesome-food",
  400. 9,
  401. "<p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent. Interdum velit euismod in pellentesque massa placerat duis. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt. Nisl rhoncus mattis rhoncus urna neque viverra justo. Odio ut enim blandit volutpat. Ac auctor augue mauris augue neque gravida. Ut lectus arcu bibendum at varius vel. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Dolor sit amet consectetur adipiscing elit duis tristique. Semper quis lectus nulla at volutpat diam ut. Sapien eget mi proin sed.</p>",
  402. "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Feugiat in ante metus dictum at tempor commodo ullamcorper a. Et malesuada fames ac turpis egestas sed tempus urna et. Euismod elementum nisi quis eleifend. Nisi porta lorem mollis aliquam ut porttitor. Ac turpis egestas maecenas pharetra convallis posuere. Nunc non blandit massa enim nec dui. Commodo elit at imperdiet dui accumsan sit amet nulla. Viverra accumsan in nisl nisi scelerisque. Dui nunc mattis enim ut tellus. Molestie ac feugiat sed lectus vestibulum mattis ullamcorper. Faucibus ornare suspendisse sed nisi lacus. Nulla facilisi morbi tempus iaculis. Ut eu sem integer vitae justo eget magna fermentum iaculis. Ullamcorper sit amet risus nullam eget felis eget nunc. Volutpat sed cras ornare arcu dui vivamus. Eget magna fermentum iaculis eu non diam.</p><p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent. Interdum velit euismod in pellentesque massa placerat duis. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt. Nisl rhoncus mattis rhoncus urna neque viverra justo. Odio ut enim blandit volutpat. Ac auctor augue mauris augue neque gravida. Ut lectus arcu bibendum at varius vel. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Dolor sit amet consectetur adipiscing elit duis tristique. Semper quis lectus nulla at volutpat diam ut. Sapien eget mi proin sed.</p>",
  403. utils.UnixTimestampToMySqlDateTime(utils.GetCurrentUnixTimestamp()),
  404. 1,
  405. ); err != nil {
  406. tx.Rollback()
  407. wrap.MsgError(err.Error())
  408. return
  409. }
  410. if _, err = tx.Exec(
  411. wrap.R.Context(),
  412. `INSERT INTO fave_blog_posts SET
  413. id = ?,
  414. user = ?,
  415. name = ?,
  416. alias = ?,
  417. category = ?,
  418. briefly = ?,
  419. content = ?,
  420. datetime = ?,
  421. active = ?
  422. ;`,
  423. 2,
  424. 1,
  425. "Latest top space movies",
  426. "latest-top-space-movies",
  427. 12,
  428. "<p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent. Interdum velit euismod in pellentesque massa placerat duis. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt. Nisl rhoncus mattis rhoncus urna neque viverra justo. Odio ut enim blandit volutpat. Ac auctor augue mauris augue neque gravida. Ut lectus arcu bibendum at varius vel. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Dolor sit amet consectetur adipiscing elit duis tristique. Semper quis lectus nulla at volutpat diam ut. Sapien eget mi proin sed.</p>",
  429. "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Feugiat in ante metus dictum at tempor commodo ullamcorper a. Et malesuada fames ac turpis egestas sed tempus urna et. Euismod elementum nisi quis eleifend. Nisi porta lorem mollis aliquam ut porttitor. Ac turpis egestas maecenas pharetra convallis posuere. Nunc non blandit massa enim nec dui. Commodo elit at imperdiet dui accumsan sit amet nulla. Viverra accumsan in nisl nisi scelerisque. Dui nunc mattis enim ut tellus. Molestie ac feugiat sed lectus vestibulum mattis ullamcorper. Faucibus ornare suspendisse sed nisi lacus. Nulla facilisi morbi tempus iaculis. Ut eu sem integer vitae justo eget magna fermentum iaculis. Ullamcorper sit amet risus nullam eget felis eget nunc. Volutpat sed cras ornare arcu dui vivamus. Eget magna fermentum iaculis eu non diam.</p><p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent. Interdum velit euismod in pellentesque massa placerat duis. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt. Nisl rhoncus mattis rhoncus urna neque viverra justo. Odio ut enim blandit volutpat. Ac auctor augue mauris augue neque gravida. Ut lectus arcu bibendum at varius vel. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Dolor sit amet consectetur adipiscing elit duis tristique. Semper quis lectus nulla at volutpat diam ut. Sapien eget mi proin sed.</p>",
  430. utils.UnixTimestampToMySqlDateTime(utils.GetCurrentUnixTimestamp()),
  431. 1,
  432. ); err != nil {
  433. tx.Rollback()
  434. wrap.MsgError(err.Error())
  435. return
  436. }
  437. if _, err = tx.Exec(
  438. wrap.R.Context(),
  439. `INSERT INTO fave_blog_posts SET
  440. id = ?,
  441. user = ?,
  442. name = ?,
  443. alias = ?,
  444. category = ?,
  445. briefly = ?,
  446. content = ?,
  447. datetime = ?,
  448. active = ?
  449. ;`,
  450. 3,
  451. 1,
  452. "The best juices for a child",
  453. "the-best-juices-for-a-child",
  454. 8,
  455. "<p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent. Interdum velit euismod in pellentesque massa placerat duis. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt. Nisl rhoncus mattis rhoncus urna neque viverra justo. Odio ut enim blandit volutpat. Ac auctor augue mauris augue neque gravida. Ut lectus arcu bibendum at varius vel. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Dolor sit amet consectetur adipiscing elit duis tristique. Semper quis lectus nulla at volutpat diam ut. Sapien eget mi proin sed.</p>",
  456. "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Feugiat in ante metus dictum at tempor commodo ullamcorper a. Et malesuada fames ac turpis egestas sed tempus urna et. Euismod elementum nisi quis eleifend. Nisi porta lorem mollis aliquam ut porttitor. Ac turpis egestas maecenas pharetra convallis posuere. Nunc non blandit massa enim nec dui. Commodo elit at imperdiet dui accumsan sit amet nulla. Viverra accumsan in nisl nisi scelerisque. Dui nunc mattis enim ut tellus. Molestie ac feugiat sed lectus vestibulum mattis ullamcorper. Faucibus ornare suspendisse sed nisi lacus. Nulla facilisi morbi tempus iaculis. Ut eu sem integer vitae justo eget magna fermentum iaculis. Ullamcorper sit amet risus nullam eget felis eget nunc. Volutpat sed cras ornare arcu dui vivamus. Eget magna fermentum iaculis eu non diam.</p><p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent. Interdum velit euismod in pellentesque massa placerat duis. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt. Nisl rhoncus mattis rhoncus urna neque viverra justo. Odio ut enim blandit volutpat. Ac auctor augue mauris augue neque gravida. Ut lectus arcu bibendum at varius vel. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Dolor sit amet consectetur adipiscing elit duis tristique. Semper quis lectus nulla at volutpat diam ut. Sapien eget mi proin sed.</p>",
  457. utils.UnixTimestampToMySqlDateTime(utils.GetCurrentUnixTimestamp()),
  458. 1,
  459. ); err != nil {
  460. tx.Rollback()
  461. wrap.MsgError(err.Error())
  462. return
  463. }
  464. if _, err = tx.Exec(
  465. wrap.R.Context(),
  466. `INSERT INTO fave_pages SET
  467. id = ?,
  468. user = ?,
  469. template = ?,
  470. name = ?,
  471. alias = ?,
  472. content = ?,
  473. datetime = ?,
  474. active = ?
  475. ;`,
  476. 1,
  477. 1,
  478. "index",
  479. "Home",
  480. "/",
  481. "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Feugiat in ante metus dictum at tempor commodo ullamcorper a. Et malesuada fames ac turpis egestas sed tempus urna et. Euismod elementum nisi quis eleifend. Nisi porta lorem mollis aliquam ut porttitor. Ac turpis egestas maecenas pharetra convallis posuere. Nunc non blandit massa enim nec dui. Commodo elit at imperdiet dui accumsan sit amet nulla. Viverra accumsan in nisl nisi scelerisque. Dui nunc mattis enim ut tellus. Molestie ac feugiat sed lectus vestibulum mattis ullamcorper. Faucibus ornare suspendisse sed nisi lacus. Nulla facilisi morbi tempus iaculis. Ut eu sem integer vitae justo eget magna fermentum iaculis. Ullamcorper sit amet risus nullam eget felis eget nunc. Volutpat sed cras ornare arcu dui vivamus. Eget magna fermentum iaculis eu non diam.</p><p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent. Interdum velit euismod in pellentesque massa placerat duis. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt. Nisl rhoncus mattis rhoncus urna neque viverra justo. Odio ut enim blandit volutpat. Ac auctor augue mauris augue neque gravida. Ut lectus arcu bibendum at varius vel. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Dolor sit amet consectetur adipiscing elit duis tristique. Semper quis lectus nulla at volutpat diam ut. Sapien eget mi proin sed.</p><p>Ante metus dictum at tempor commodo ullamcorper a. Facilisis mauris sit amet massa vitae. Enim neque volutpat ac tincidunt vitae. Tempus quam pellentesque nec nam aliquam sem. Mollis aliquam ut porttitor leo a diam sollicitudin. Nunc pulvinar sapien et ligula ullamcorper. Dignissim suspendisse in est ante in nibh mauris. Eget egestas purus viverra accumsan in. Vitae tempus quam pellentesque nec nam aliquam sem et. Sodales ut etiam sit amet nisl. Aliquet risus feugiat in ante. Rhoncus urna neque viverra justo nec ultrices dui sapien. Sit amet aliquam id diam maecenas ultricies. Sed odio morbi quis commodo odio aenean sed adipiscing diam.</p>",
  482. utils.UnixTimestampToMySqlDateTime(utils.GetCurrentUnixTimestamp()),
  483. 1,
  484. ); err != nil {
  485. tx.Rollback()
  486. wrap.MsgError(err.Error())
  487. return
  488. }
  489. if _, err = tx.Exec(
  490. wrap.R.Context(),
  491. `INSERT INTO fave_pages SET
  492. id = ?,
  493. user = ?,
  494. template = ?,
  495. name = ?,
  496. alias = ?,
  497. content = ?,
  498. datetime = ?,
  499. active = ?
  500. ;`,
  501. 2,
  502. 1,
  503. "page",
  504. "Another",
  505. "/another/",
  506. "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Feugiat in ante metus dictum at tempor commodo ullamcorper a. Et malesuada fames ac turpis egestas sed tempus urna et. Euismod elementum nisi quis eleifend. Nisi porta lorem mollis aliquam ut porttitor. Ac turpis egestas maecenas pharetra convallis posuere. Nunc non blandit massa enim nec dui. Commodo elit at imperdiet dui accumsan sit amet nulla. Viverra accumsan in nisl nisi scelerisque. Dui nunc mattis enim ut tellus. Molestie ac feugiat sed lectus vestibulum mattis ullamcorper. Faucibus ornare suspendisse sed nisi lacus. Nulla facilisi morbi tempus iaculis. Ut eu sem integer vitae justo eget magna fermentum iaculis. Ullamcorper sit amet risus nullam eget felis eget nunc. Volutpat sed cras ornare arcu dui vivamus. Eget magna fermentum iaculis eu non diam.</p><p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent. Interdum velit euismod in pellentesque massa placerat duis. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt. Nisl rhoncus mattis rhoncus urna neque viverra justo. Odio ut enim blandit volutpat. Ac auctor augue mauris augue neque gravida. Ut lectus arcu bibendum at varius vel. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Dolor sit amet consectetur adipiscing elit duis tristique. Semper quis lectus nulla at volutpat diam ut. Sapien eget mi proin sed.</p><p>Ante metus dictum at tempor commodo ullamcorper a. Facilisis mauris sit amet massa vitae. Enim neque volutpat ac tincidunt vitae. Tempus quam pellentesque nec nam aliquam sem. Mollis aliquam ut porttitor leo a diam sollicitudin. Nunc pulvinar sapien et ligula ullamcorper. Dignissim suspendisse in est ante in nibh mauris. Eget egestas purus viverra accumsan in. Vitae tempus quam pellentesque nec nam aliquam sem et. Sodales ut etiam sit amet nisl. Aliquet risus feugiat in ante. Rhoncus urna neque viverra justo nec ultrices dui sapien. Sit amet aliquam id diam maecenas ultricies. Sed odio morbi quis commodo odio aenean sed adipiscing diam.</p>",
  507. utils.UnixTimestampToMySqlDateTime(utils.GetCurrentUnixTimestamp()),
  508. 1,
  509. ); err != nil {
  510. tx.Rollback()
  511. wrap.MsgError(err.Error())
  512. return
  513. }
  514. if _, err = tx.Exec(
  515. wrap.R.Context(),
  516. `INSERT INTO fave_pages SET
  517. id = ?,
  518. user = ?,
  519. template = ?,
  520. name = ?,
  521. alias = ?,
  522. content = ?,
  523. datetime = ?,
  524. active = ?
  525. ;`,
  526. 3,
  527. 1,
  528. "page",
  529. "About",
  530. "/about/",
  531. "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Feugiat in ante metus dictum at tempor commodo ullamcorper a. Et malesuada fames ac turpis egestas sed tempus urna et. Euismod elementum nisi quis eleifend. Nisi porta lorem mollis aliquam ut porttitor. Ac turpis egestas maecenas pharetra convallis posuere. Nunc non blandit massa enim nec dui. Commodo elit at imperdiet dui accumsan sit amet nulla. Viverra accumsan in nisl nisi scelerisque. Dui nunc mattis enim ut tellus. Molestie ac feugiat sed lectus vestibulum mattis ullamcorper. Faucibus ornare suspendisse sed nisi lacus. Nulla facilisi morbi tempus iaculis. Ut eu sem integer vitae justo eget magna fermentum iaculis. Ullamcorper sit amet risus nullam eget felis eget nunc. Volutpat sed cras ornare arcu dui vivamus. Eget magna fermentum iaculis eu non diam.</p><p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent. Interdum velit euismod in pellentesque massa placerat duis. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt. Nisl rhoncus mattis rhoncus urna neque viverra justo. Odio ut enim blandit volutpat. Ac auctor augue mauris augue neque gravida. Ut lectus arcu bibendum at varius vel. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Dolor sit amet consectetur adipiscing elit duis tristique. Semper quis lectus nulla at volutpat diam ut. Sapien eget mi proin sed.</p><p>Ante metus dictum at tempor commodo ullamcorper a. Facilisis mauris sit amet massa vitae. Enim neque volutpat ac tincidunt vitae. Tempus quam pellentesque nec nam aliquam sem. Mollis aliquam ut porttitor leo a diam sollicitudin. Nunc pulvinar sapien et ligula ullamcorper. Dignissim suspendisse in est ante in nibh mauris. Eget egestas purus viverra accumsan in. Vitae tempus quam pellentesque nec nam aliquam sem et. Sodales ut etiam sit amet nisl. Aliquet risus feugiat in ante. Rhoncus urna neque viverra justo nec ultrices dui sapien. Sit amet aliquam id diam maecenas ultricies. Sed odio morbi quis commodo odio aenean sed adipiscing diam.</p>",
  532. utils.UnixTimestampToMySqlDateTime(utils.GetCurrentUnixTimestamp()),
  533. 1,
  534. ); err != nil {
  535. tx.Rollback()
  536. wrap.MsgError(err.Error())
  537. return
  538. }
  539. if _, err = tx.Exec(
  540. wrap.R.Context(),
  541. `INSERT INTO fave_settings (name, value) VALUES ('database_version', '000000024');`,
  542. ); err != nil {
  543. tx.Rollback()
  544. wrap.MsgError(err.Error())
  545. return
  546. }
  547. if _, err = tx.Exec(
  548. wrap.R.Context(),
  549. `INSERT INTO fave_shop_cat_product_rel (product_id, category_id)
  550. VALUES
  551. (1, 3),
  552. (2, 3),
  553. (3, 3);`,
  554. ); err != nil {
  555. tx.Rollback()
  556. wrap.MsgError(err.Error())
  557. return
  558. }
  559. if _, err = tx.Exec(
  560. wrap.R.Context(),
  561. `INSERT INTO fave_shop_cats (id, user, name, alias, lft, rgt)
  562. VALUES
  563. (1, 1, 'ROOT', 'ROOT', 1, 6),
  564. (2, 1, 'Electronics', 'electronics', 2, 5),
  565. (3, 1, 'Mobile phones', 'mobile-phones', 3, 4);`,
  566. ); err != nil {
  567. tx.Rollback()
  568. wrap.MsgError(err.Error())
  569. return
  570. }
  571. if _, err = tx.Exec(
  572. wrap.R.Context(),
  573. `INSERT INTO fave_shop_currencies (id, name, coefficient, code, symbol)
  574. VALUES
  575. (1, 'US Dollar', 1.0000, 'USD', '$'),
  576. (2, 'UA Grivna', 25.0000, 'UAH', '₴');`,
  577. ); err != nil {
  578. tx.Rollback()
  579. wrap.MsgError(err.Error())
  580. return
  581. }
  582. if _, err = tx.Exec(
  583. wrap.R.Context(),
  584. `INSERT INTO fave_shop_filter_product_values (product_id, filter_value_id)
  585. VALUES
  586. (1, 3),
  587. (1, 7),
  588. (1, 10),
  589. (1, 11),
  590. (1, 12),
  591. (2, 3),
  592. (2, 8),
  593. (2, 10),
  594. (2, 11),
  595. (2, 12),
  596. (3, 3),
  597. (3, 9),
  598. (3, 10),
  599. (3, 11),
  600. (3, 12);`,
  601. ); err != nil {
  602. tx.Rollback()
  603. wrap.MsgError(err.Error())
  604. return
  605. }
  606. if _, err = tx.Exec(
  607. wrap.R.Context(),
  608. `INSERT INTO fave_shop_filters (id, name, filter)
  609. VALUES
  610. (1, 'Mobile phones manufacturer', 'Manufacturer'),
  611. (2, 'Mobile phones memory', 'Memory'),
  612. (3, 'Mobile phones communication standard', 'Communication standard');`,
  613. ); err != nil {
  614. tx.Rollback()
  615. wrap.MsgError(err.Error())
  616. return
  617. }
  618. if _, err = tx.Exec(
  619. wrap.R.Context(),
  620. `INSERT INTO fave_shop_filters_values (id, filter_id, name)
  621. VALUES
  622. (1, 1, 'Apple'),
  623. (2, 1, 'Asus'),
  624. (3, 1, 'Samsung'),
  625. (4, 2, '16 Gb'),
  626. (5, 2, '32 Gb'),
  627. (6, 2, '64 Gb'),
  628. (7, 2, '128 Gb'),
  629. (8, 2, '256 Gb'),
  630. (9, 2, '512 Gb'),
  631. (10, 3, '4G'),
  632. (11, 3, '2G'),
  633. (12, 3, '3G');`,
  634. ); err != nil {
  635. tx.Rollback()
  636. wrap.MsgError(err.Error())
  637. return
  638. }
  639. if _, err = tx.Exec(
  640. wrap.R.Context(),
  641. `INSERT INTO fave_shop_products SET
  642. id = ?,
  643. user = ?,
  644. currency = ?,
  645. price = ?,
  646. price_old = ?,
  647. gname = ?,
  648. name = ?,
  649. alias = ?,
  650. vendor = ?,
  651. quantity = ?,
  652. category = ?,
  653. briefly = ?,
  654. content = ?,
  655. datetime = ?,
  656. active = ?
  657. ;`,
  658. 1,
  659. 1,
  660. 1,
  661. 999.00,
  662. 1100.00,
  663. "Samsung Galaxy S10",
  664. "Samsung Galaxy S10 (128 Gb)",
  665. "samsung-galaxy-s10-128-gb",
  666. "Samsung",
  667. "1",
  668. "3",
  669. "<p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent.</p>",
  670. "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Feugiat in ante metus dictum at tempor commodo ullamcorper a. Et malesuada fames ac turpis egestas sed tempus urna et. Euismod elementum nisi quis eleifend. Nisi porta lorem mollis aliquam ut porttitor. Ac turpis egestas maecenas pharetra convallis posuere. Nunc non blandit massa enim nec dui. Commodo elit at imperdiet dui accumsan sit amet nulla. Viverra accumsan in nisl nisi scelerisque. Dui nunc mattis enim ut tellus. Molestie ac feugiat sed lectus vestibulum mattis ullamcorper. Faucibus ornare suspendisse sed nisi lacus. Nulla facilisi morbi tempus iaculis. Ut eu sem integer vitae justo eget magna fermentum iaculis. Ullamcorper sit amet risus nullam eget felis eget nunc. Volutpat sed cras ornare arcu dui vivamus. Eget magna fermentum iaculis eu non diam.</p><p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent. Interdum velit euismod in pellentesque massa placerat duis. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt. Nisl rhoncus mattis rhoncus urna neque viverra justo. Odio ut enim blandit volutpat. Ac auctor augue mauris augue neque gravida. Ut lectus arcu bibendum at varius vel. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Dolor sit amet consectetur adipiscing elit duis tristique. Semper quis lectus nulla at volutpat diam ut. Sapien eget mi proin sed.</p>",
  671. utils.UnixTimestampToMySqlDateTime(utils.GetCurrentUnixTimestamp()),
  672. 1,
  673. ); err != nil {
  674. tx.Rollback()
  675. wrap.MsgError(err.Error())
  676. return
  677. }
  678. if _, err = tx.Exec(
  679. wrap.R.Context(),
  680. `INSERT INTO fave_shop_products SET
  681. id = ?,
  682. parent_id = ?,
  683. user = ?,
  684. currency = ?,
  685. price = ?,
  686. price_old = ?,
  687. gname = ?,
  688. name = ?,
  689. alias = ?,
  690. vendor = ?,
  691. quantity = ?,
  692. category = ?,
  693. briefly = ?,
  694. content = ?,
  695. datetime = ?,
  696. active = ?
  697. ;`,
  698. 2,
  699. 1,
  700. 1,
  701. 1,
  702. 1999.00,
  703. 1300.00,
  704. "",
  705. "Samsung Galaxy S10 (256 Gb)",
  706. "samsung-galaxy-s10-256-gb",
  707. "Samsung",
  708. "1",
  709. "3",
  710. "<p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent.</p>",
  711. "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Feugiat in ante metus dictum at tempor commodo ullamcorper a. Et malesuada fames ac turpis egestas sed tempus urna et. Euismod elementum nisi quis eleifend. Nisi porta lorem mollis aliquam ut porttitor. Ac turpis egestas maecenas pharetra convallis posuere. Nunc non blandit massa enim nec dui. Commodo elit at imperdiet dui accumsan sit amet nulla. Viverra accumsan in nisl nisi scelerisque. Dui nunc mattis enim ut tellus. Molestie ac feugiat sed lectus vestibulum mattis ullamcorper. Faucibus ornare suspendisse sed nisi lacus. Nulla facilisi morbi tempus iaculis. Ut eu sem integer vitae justo eget magna fermentum iaculis. Ullamcorper sit amet risus nullam eget felis eget nunc. Volutpat sed cras ornare arcu dui vivamus. Eget magna fermentum iaculis eu non diam.</p><p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent. Interdum velit euismod in pellentesque massa placerat duis. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt. Nisl rhoncus mattis rhoncus urna neque viverra justo. Odio ut enim blandit volutpat. Ac auctor augue mauris augue neque gravida. Ut lectus arcu bibendum at varius vel. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Dolor sit amet consectetur adipiscing elit duis tristique. Semper quis lectus nulla at volutpat diam ut. Sapien eget mi proin sed.</p>",
  712. utils.UnixTimestampToMySqlDateTime(utils.GetCurrentUnixTimestamp()),
  713. 1,
  714. ); err != nil {
  715. tx.Rollback()
  716. wrap.MsgError(err.Error())
  717. return
  718. }
  719. if _, err = tx.Exec(
  720. wrap.R.Context(),
  721. `INSERT INTO fave_shop_products SET
  722. id = ?,
  723. parent_id = ?,
  724. user = ?,
  725. currency = ?,
  726. price = ?,
  727. price_old = ?,
  728. gname = ?,
  729. name = ?,
  730. alias = ?,
  731. vendor = ?,
  732. quantity = ?,
  733. category = ?,
  734. briefly = ?,
  735. content = ?,
  736. datetime = ?,
  737. active = ?
  738. ;`,
  739. 3,
  740. 1,
  741. 1,
  742. 1,
  743. 2999.00,
  744. 2300.00,
  745. "",
  746. "Samsung Galaxy S10 (512 Gb)",
  747. "samsung-galaxy-s10-512-gb",
  748. "Samsung",
  749. "0",
  750. "3",
  751. "<p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent.</p>",
  752. "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Feugiat in ante metus dictum at tempor commodo ullamcorper a. Et malesuada fames ac turpis egestas sed tempus urna et. Euismod elementum nisi quis eleifend. Nisi porta lorem mollis aliquam ut porttitor. Ac turpis egestas maecenas pharetra convallis posuere. Nunc non blandit massa enim nec dui. Commodo elit at imperdiet dui accumsan sit amet nulla. Viverra accumsan in nisl nisi scelerisque. Dui nunc mattis enim ut tellus. Molestie ac feugiat sed lectus vestibulum mattis ullamcorper. Faucibus ornare suspendisse sed nisi lacus. Nulla facilisi morbi tempus iaculis. Ut eu sem integer vitae justo eget magna fermentum iaculis. Ullamcorper sit amet risus nullam eget felis eget nunc. Volutpat sed cras ornare arcu dui vivamus. Eget magna fermentum iaculis eu non diam.</p><p>Arcu ac tortor dignissim convallis aenean et tortor. Vitae auctor eu augue ut lectus arcu. Ac turpis egestas integer eget aliquet nibh praesent. Interdum velit euismod in pellentesque massa placerat duis. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt. Nisl rhoncus mattis rhoncus urna neque viverra justo. Odio ut enim blandit volutpat. Ac auctor augue mauris augue neque gravida. Ut lectus arcu bibendum at varius vel. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Dolor sit amet consectetur adipiscing elit duis tristique. Semper quis lectus nulla at volutpat diam ut. Sapien eget mi proin sed.</p>",
  753. utils.UnixTimestampToMySqlDateTime(utils.GetCurrentUnixTimestamp()),
  754. 1,
  755. ); err != nil {
  756. tx.Rollback()
  757. wrap.MsgError(err.Error())
  758. return
  759. }
  760. if _, err = tx.Exec(
  761. wrap.R.Context(),
  762. `INSERT INTO fave_users (id, first_name, last_name, email, password, admin, active) VALUES (1, 'First Name', 'Last Name', 'example@example.com', '23463b99b62a72f26ed677cc556c44e8', 1, 1);`,
  763. ); err != nil {
  764. tx.Rollback()
  765. wrap.MsgError(err.Error())
  766. return
  767. }
  768. // Indexes
  769. if _, err = tx.Exec(
  770. wrap.R.Context(),
  771. `ALTER TABLE fave_blog_cat_post_rel ADD UNIQUE KEY post_category (post_id,category_id) USING BTREE;`,
  772. ); err != nil {
  773. tx.Rollback()
  774. wrap.MsgError(err.Error())
  775. return
  776. }
  777. if _, err = tx.Exec(
  778. wrap.R.Context(),
  779. `ALTER TABLE fave_blog_cat_post_rel ADD KEY FK_blog_cat_post_rel_post_id (post_id);`,
  780. ); err != nil {
  781. tx.Rollback()
  782. wrap.MsgError(err.Error())
  783. return
  784. }
  785. if _, err = tx.Exec(
  786. wrap.R.Context(),
  787. `ALTER TABLE fave_blog_cat_post_rel ADD KEY FK_blog_cat_post_rel_category_id (category_id);`,
  788. ); err != nil {
  789. tx.Rollback()
  790. wrap.MsgError(err.Error())
  791. return
  792. }
  793. if _, err = tx.Exec(
  794. wrap.R.Context(),
  795. `ALTER TABLE fave_blog_cats ADD UNIQUE KEY alias (alias);`,
  796. ); err != nil {
  797. tx.Rollback()
  798. wrap.MsgError(err.Error())
  799. return
  800. }
  801. if _, err = tx.Exec(
  802. wrap.R.Context(),
  803. `ALTER TABLE fave_blog_cats ADD KEY lft (lft), ADD KEY rgt (rgt);`,
  804. ); err != nil {
  805. tx.Rollback()
  806. wrap.MsgError(err.Error())
  807. return
  808. }
  809. if _, err = tx.Exec(
  810. wrap.R.Context(),
  811. `ALTER TABLE fave_blog_cats ADD KEY FK_blog_cats_user (user);`,
  812. ); err != nil {
  813. tx.Rollback()
  814. wrap.MsgError(err.Error())
  815. return
  816. }
  817. if _, err = tx.Exec(
  818. wrap.R.Context(),
  819. `ALTER TABLE fave_blog_posts ADD UNIQUE KEY alias (alias);`,
  820. ); err != nil {
  821. tx.Rollback()
  822. wrap.MsgError(err.Error())
  823. return
  824. }
  825. if _, err = tx.Exec(
  826. wrap.R.Context(),
  827. `ALTER TABLE fave_blog_posts ADD KEY FK_blog_posts_user (user);`,
  828. ); err != nil {
  829. tx.Rollback()
  830. wrap.MsgError(err.Error())
  831. return
  832. }
  833. if _, err = tx.Exec(
  834. wrap.R.Context(),
  835. `ALTER TABLE fave_blog_posts ADD KEY FK_blog_posts_category (category);`,
  836. ); err != nil {
  837. tx.Rollback()
  838. wrap.MsgError(err.Error())
  839. return
  840. }
  841. if _, err = tx.Exec(
  842. wrap.R.Context(),
  843. `ALTER TABLE fave_notify_mail ADD KEY status (status);`,
  844. ); err != nil {
  845. tx.Rollback()
  846. wrap.MsgError(err.Error())
  847. return
  848. }
  849. if _, err = tx.Exec(
  850. wrap.R.Context(),
  851. `ALTER TABLE fave_pages ADD UNIQUE KEY alias (alias);`,
  852. ); err != nil {
  853. tx.Rollback()
  854. wrap.MsgError(err.Error())
  855. return
  856. }
  857. if _, err = tx.Exec(
  858. wrap.R.Context(),
  859. `ALTER TABLE fave_pages ADD KEY alias_active (alias,active) USING BTREE;`,
  860. ); err != nil {
  861. tx.Rollback()
  862. wrap.MsgError(err.Error())
  863. return
  864. }
  865. if _, err = tx.Exec(
  866. wrap.R.Context(),
  867. `ALTER TABLE fave_pages ADD KEY FK_pages_user (user);`,
  868. ); err != nil {
  869. tx.Rollback()
  870. wrap.MsgError(err.Error())
  871. return
  872. }
  873. if _, err = tx.Exec(
  874. wrap.R.Context(),
  875. `ALTER TABLE fave_settings ADD UNIQUE KEY name (name);`,
  876. ); err != nil {
  877. tx.Rollback()
  878. wrap.MsgError(err.Error())
  879. return
  880. }
  881. if _, err = tx.Exec(
  882. wrap.R.Context(),
  883. `ALTER TABLE fave_shop_cat_product_rel ADD UNIQUE KEY product_category (product_id,category_id) USING BTREE;`,
  884. ); err != nil {
  885. tx.Rollback()
  886. wrap.MsgError(err.Error())
  887. return
  888. }
  889. if _, err = tx.Exec(
  890. wrap.R.Context(),
  891. `ALTER TABLE fave_shop_cat_product_rel ADD KEY FK_shop_cat_product_rel_product_id (product_id);`,
  892. ); err != nil {
  893. tx.Rollback()
  894. wrap.MsgError(err.Error())
  895. return
  896. }
  897. if _, err = tx.Exec(
  898. wrap.R.Context(),
  899. `ALTER TABLE fave_shop_cat_product_rel ADD KEY FK_shop_cat_product_rel_category_id (category_id);`,
  900. ); err != nil {
  901. tx.Rollback()
  902. wrap.MsgError(err.Error())
  903. return
  904. }
  905. if _, err = tx.Exec(
  906. wrap.R.Context(),
  907. `ALTER TABLE fave_shop_cats ADD UNIQUE KEY alias (alias);`,
  908. ); err != nil {
  909. tx.Rollback()
  910. wrap.MsgError(err.Error())
  911. return
  912. }
  913. if _, err = tx.Exec(
  914. wrap.R.Context(),
  915. `ALTER TABLE fave_shop_cats ADD KEY lft (lft), ADD KEY rgt (rgt);`,
  916. ); err != nil {
  917. tx.Rollback()
  918. wrap.MsgError(err.Error())
  919. return
  920. }
  921. if _, err = tx.Exec(
  922. wrap.R.Context(),
  923. `ALTER TABLE fave_shop_cats ADD KEY FK_shop_cats_user (user);`,
  924. ); err != nil {
  925. tx.Rollback()
  926. wrap.MsgError(err.Error())
  927. return
  928. }
  929. if _, err = tx.Exec(
  930. wrap.R.Context(),
  931. `ALTER TABLE fave_shop_filter_product_values ADD UNIQUE KEY product_filter_value (product_id,filter_value_id) USING BTREE;`,
  932. ); err != nil {
  933. tx.Rollback()
  934. wrap.MsgError(err.Error())
  935. return
  936. }
  937. if _, err = tx.Exec(
  938. wrap.R.Context(),
  939. `ALTER TABLE fave_shop_filter_product_values ADD KEY FK_shop_filter_product_values_product_id (product_id);`,
  940. ); err != nil {
  941. tx.Rollback()
  942. wrap.MsgError(err.Error())
  943. return
  944. }
  945. if _, err = tx.Exec(
  946. wrap.R.Context(),
  947. `ALTER TABLE fave_shop_filter_product_values ADD KEY FK_shop_filter_product_values_filter_value_id (filter_value_id);`,
  948. ); err != nil {
  949. tx.Rollback()
  950. wrap.MsgError(err.Error())
  951. return
  952. }
  953. if _, err = tx.Exec(
  954. wrap.R.Context(),
  955. `ALTER TABLE fave_shop_filters ADD KEY name (name);`,
  956. ); err != nil {
  957. tx.Rollback()
  958. wrap.MsgError(err.Error())
  959. return
  960. }
  961. if _, err = tx.Exec(
  962. wrap.R.Context(),
  963. `ALTER TABLE fave_shop_filters_values ADD KEY FK_shop_filters_values_filter_id (filter_id);`,
  964. ); err != nil {
  965. tx.Rollback()
  966. wrap.MsgError(err.Error())
  967. return
  968. }
  969. if _, err = tx.Exec(
  970. wrap.R.Context(),
  971. `ALTER TABLE fave_shop_filters_values ADD KEY name (name);`,
  972. ); err != nil {
  973. tx.Rollback()
  974. wrap.MsgError(err.Error())
  975. return
  976. }
  977. if _, err = tx.Exec(
  978. wrap.R.Context(),
  979. `ALTER TABLE fave_shop_orders ADD KEY FK_shop_orders_currency_id (currency_id);`,
  980. ); err != nil {
  981. tx.Rollback()
  982. wrap.MsgError(err.Error())
  983. return
  984. }
  985. if _, err = tx.Exec(
  986. wrap.R.Context(),
  987. `ALTER TABLE fave_shop_order_products ADD UNIQUE KEY order_product (order_id,product_id) USING BTREE;`,
  988. ); err != nil {
  989. tx.Rollback()
  990. wrap.MsgError(err.Error())
  991. return
  992. }
  993. if _, err = tx.Exec(
  994. wrap.R.Context(),
  995. `ALTER TABLE fave_shop_order_products ADD KEY FK_shop_order_products_order_id (order_id);`,
  996. ); err != nil {
  997. tx.Rollback()
  998. wrap.MsgError(err.Error())
  999. return
  1000. }
  1001. if _, err = tx.Exec(
  1002. wrap.R.Context(),
  1003. `ALTER TABLE fave_shop_order_products ADD KEY FK_shop_order_products_product_id (product_id);`,
  1004. ); err != nil {
  1005. tx.Rollback()
  1006. wrap.MsgError(err.Error())
  1007. return
  1008. }
  1009. if _, err = tx.Exec(
  1010. wrap.R.Context(),
  1011. `ALTER TABLE fave_shop_product_images ADD UNIQUE KEY product_filename (product_id,filename) USING BTREE;`,
  1012. ); err != nil {
  1013. tx.Rollback()
  1014. wrap.MsgError(err.Error())
  1015. return
  1016. }
  1017. if _, err = tx.Exec(
  1018. wrap.R.Context(),
  1019. `ALTER TABLE fave_shop_product_images ADD KEY FK_shop_product_images_product_id (product_id);`,
  1020. ); err != nil {
  1021. tx.Rollback()
  1022. wrap.MsgError(err.Error())
  1023. return
  1024. }
  1025. if _, err = tx.Exec(
  1026. wrap.R.Context(),
  1027. `ALTER TABLE fave_shop_products ADD UNIQUE KEY alias (alias);`,
  1028. ); err != nil {
  1029. tx.Rollback()
  1030. wrap.MsgError(err.Error())
  1031. return
  1032. }
  1033. if _, err = tx.Exec(
  1034. wrap.R.Context(),
  1035. `ALTER TABLE fave_shop_products ADD KEY FK_shop_products_user (user);`,
  1036. ); err != nil {
  1037. tx.Rollback()
  1038. wrap.MsgError(err.Error())
  1039. return
  1040. }
  1041. if _, err = tx.Exec(
  1042. wrap.R.Context(),
  1043. `ALTER TABLE fave_shop_products ADD KEY FK_shop_products_currency (currency);`,
  1044. ); err != nil {
  1045. tx.Rollback()
  1046. wrap.MsgError(err.Error())
  1047. return
  1048. }
  1049. if _, err = tx.Exec(
  1050. wrap.R.Context(),
  1051. `ALTER TABLE fave_shop_products ADD KEY FK_shop_products_category (category);`,
  1052. ); err != nil {
  1053. tx.Rollback()
  1054. wrap.MsgError(err.Error())
  1055. return
  1056. }
  1057. if _, err = tx.Exec(
  1058. wrap.R.Context(),
  1059. `ALTER TABLE fave_shop_products ADD KEY FK_shop_products_parent_id (parent_id);`,
  1060. ); err != nil {
  1061. tx.Rollback()
  1062. wrap.MsgError(err.Error())
  1063. return
  1064. }
  1065. if _, err = tx.Exec(
  1066. wrap.R.Context(),
  1067. `ALTER TABLE fave_shop_products ADD KEY name (name);`,
  1068. ); err != nil {
  1069. tx.Rollback()
  1070. wrap.MsgError(err.Error())
  1071. return
  1072. }
  1073. if _, err = tx.Exec(
  1074. wrap.R.Context(),
  1075. `ALTER TABLE fave_users ADD UNIQUE KEY email (email);`,
  1076. ); err != nil {
  1077. tx.Rollback()
  1078. wrap.MsgError(err.Error())
  1079. return
  1080. }
  1081. // References
  1082. if _, err = tx.Exec(
  1083. wrap.R.Context(),
  1084. `ALTER TABLE fave_blog_cat_post_rel ADD CONSTRAINT FK_blog_cat_post_rel_post_id
  1085. FOREIGN KEY (post_id) REFERENCES fave_blog_posts (id) ON DELETE RESTRICT;
  1086. `); err != nil {
  1087. tx.Rollback()
  1088. wrap.MsgError(err.Error())
  1089. return
  1090. }
  1091. if _, err = tx.Exec(
  1092. wrap.R.Context(),
  1093. `ALTER TABLE fave_blog_cat_post_rel ADD CONSTRAINT FK_blog_cat_post_rel_category_id
  1094. FOREIGN KEY (category_id) REFERENCES fave_blog_cats (id) ON DELETE RESTRICT;
  1095. `); err != nil {
  1096. tx.Rollback()
  1097. wrap.MsgError(err.Error())
  1098. return
  1099. }
  1100. if _, err = tx.Exec(
  1101. wrap.R.Context(),
  1102. `ALTER TABLE fave_blog_cats ADD CONSTRAINT FK_blog_cats_user
  1103. FOREIGN KEY (user) REFERENCES fave_users (id) ON DELETE RESTRICT;
  1104. `); err != nil {
  1105. tx.Rollback()
  1106. wrap.MsgError(err.Error())
  1107. return
  1108. }
  1109. if _, err = tx.Exec(
  1110. wrap.R.Context(),
  1111. `ALTER TABLE fave_blog_posts ADD CONSTRAINT FK_blog_posts_user
  1112. FOREIGN KEY (user) REFERENCES fave_users (id) ON DELETE RESTRICT;
  1113. `); err != nil {
  1114. tx.Rollback()
  1115. wrap.MsgError(err.Error())
  1116. return
  1117. }
  1118. if _, err = tx.Exec(
  1119. wrap.R.Context(),
  1120. `ALTER TABLE fave_blog_posts ADD CONSTRAINT FK_blog_posts_category
  1121. FOREIGN KEY (category) REFERENCES fave_blog_cats (id) ON DELETE RESTRICT;
  1122. `); err != nil {
  1123. tx.Rollback()
  1124. wrap.MsgError(err.Error())
  1125. return
  1126. }
  1127. if _, err = tx.Exec(
  1128. wrap.R.Context(),
  1129. `ALTER TABLE fave_pages ADD CONSTRAINT FK_pages_user
  1130. FOREIGN KEY (user) REFERENCES fave_users (id) ON DELETE RESTRICT;
  1131. `); err != nil {
  1132. tx.Rollback()
  1133. wrap.MsgError(err.Error())
  1134. return
  1135. }
  1136. if _, err = tx.Exec(
  1137. wrap.R.Context(),
  1138. `ALTER TABLE fave_shop_cat_product_rel ADD CONSTRAINT FK_shop_cat_product_rel_product_id
  1139. FOREIGN KEY (product_id) REFERENCES fave_shop_products (id) ON DELETE RESTRICT;
  1140. `); err != nil {
  1141. tx.Rollback()
  1142. wrap.MsgError(err.Error())
  1143. return
  1144. }
  1145. if _, err = tx.Exec(
  1146. wrap.R.Context(),
  1147. `ALTER TABLE fave_shop_cat_product_rel ADD CONSTRAINT FK_shop_cat_product_rel_category_id
  1148. FOREIGN KEY (category_id) REFERENCES fave_shop_cats (id) ON DELETE RESTRICT;
  1149. `); err != nil {
  1150. tx.Rollback()
  1151. wrap.MsgError(err.Error())
  1152. return
  1153. }
  1154. if _, err = tx.Exec(
  1155. wrap.R.Context(),
  1156. `ALTER TABLE fave_shop_cats ADD CONSTRAINT FK_shop_cats_user
  1157. FOREIGN KEY (user) REFERENCES fave_users (id) ON DELETE RESTRICT;
  1158. `); err != nil {
  1159. tx.Rollback()
  1160. wrap.MsgError(err.Error())
  1161. return
  1162. }
  1163. if _, err = tx.Exec(
  1164. wrap.R.Context(),
  1165. `ALTER TABLE fave_shop_filter_product_values ADD CONSTRAINT FK_shop_filter_product_values_product_id
  1166. FOREIGN KEY (product_id) REFERENCES fave_shop_products (id) ON DELETE RESTRICT;
  1167. `); err != nil {
  1168. tx.Rollback()
  1169. wrap.MsgError(err.Error())
  1170. return
  1171. }
  1172. if _, err = tx.Exec(
  1173. wrap.R.Context(),
  1174. `ALTER TABLE fave_shop_filter_product_values ADD CONSTRAINT FK_shop_filter_product_values_filter_value_id
  1175. FOREIGN KEY (filter_value_id) REFERENCES fave_shop_filters_values (id) ON DELETE RESTRICT;
  1176. `); err != nil {
  1177. tx.Rollback()
  1178. wrap.MsgError(err.Error())
  1179. return
  1180. }
  1181. if _, err = tx.Exec(
  1182. wrap.R.Context(),
  1183. `ALTER TABLE fave_shop_filters_values ADD CONSTRAINT FK_shop_filters_values_filter_id
  1184. FOREIGN KEY (filter_id) REFERENCES fave_shop_filters (id) ON DELETE RESTRICT;
  1185. `); err != nil {
  1186. tx.Rollback()
  1187. wrap.MsgError(err.Error())
  1188. return
  1189. }
  1190. if _, err = tx.Exec(
  1191. wrap.R.Context(),
  1192. `ALTER TABLE fave_shop_orders ADD CONSTRAINT FK_shop_orders_currency_id
  1193. FOREIGN KEY (currency_id) REFERENCES fave_shop_currencies (id) ON DELETE RESTRICT;
  1194. `); err != nil {
  1195. tx.Rollback()
  1196. wrap.MsgError(err.Error())
  1197. return
  1198. }
  1199. if _, err = tx.Exec(
  1200. wrap.R.Context(),
  1201. `ALTER TABLE fave_shop_order_products ADD CONSTRAINT FK_shop_order_products_order_id
  1202. FOREIGN KEY (order_id) REFERENCES fave_shop_orders (id) ON DELETE RESTRICT;
  1203. `); err != nil {
  1204. tx.Rollback()
  1205. wrap.MsgError(err.Error())
  1206. return
  1207. }
  1208. if _, err = tx.Exec(
  1209. wrap.R.Context(),
  1210. `ALTER TABLE fave_shop_order_products ADD CONSTRAINT FK_shop_order_products_product_id
  1211. FOREIGN KEY (product_id) REFERENCES fave_shop_products (id) ON DELETE RESTRICT;
  1212. `); err != nil {
  1213. tx.Rollback()
  1214. wrap.MsgError(err.Error())
  1215. return
  1216. }
  1217. if _, err = tx.Exec(
  1218. wrap.R.Context(),
  1219. `ALTER TABLE fave_shop_product_images ADD CONSTRAINT FK_shop_product_images_product_id
  1220. FOREIGN KEY (product_id) REFERENCES fave_shop_products (id) ON DELETE RESTRICT;
  1221. `); err != nil {
  1222. tx.Rollback()
  1223. wrap.MsgError(err.Error())
  1224. return
  1225. }
  1226. if _, err = tx.Exec(
  1227. wrap.R.Context(),
  1228. `ALTER TABLE fave_shop_products ADD CONSTRAINT FK_shop_products_user
  1229. FOREIGN KEY (user) REFERENCES fave_users (id) ON DELETE RESTRICT;
  1230. `); err != nil {
  1231. tx.Rollback()
  1232. wrap.MsgError(err.Error())
  1233. return
  1234. }
  1235. if _, err = tx.Exec(
  1236. wrap.R.Context(),
  1237. `ALTER TABLE fave_shop_products ADD CONSTRAINT FK_shop_products_currency
  1238. FOREIGN KEY (currency) REFERENCES fave_shop_currencies (id) ON DELETE RESTRICT;
  1239. `); err != nil {
  1240. tx.Rollback()
  1241. wrap.MsgError(err.Error())
  1242. return
  1243. }
  1244. if _, err = tx.Exec(
  1245. wrap.R.Context(),
  1246. `ALTER TABLE fave_shop_products ADD CONSTRAINT FK_shop_products_category
  1247. FOREIGN KEY (category) REFERENCES fave_shop_cats (id) ON DELETE RESTRICT;
  1248. `); err != nil {
  1249. tx.Rollback()
  1250. wrap.MsgError(err.Error())
  1251. return
  1252. }
  1253. if _, err = tx.Exec(
  1254. wrap.R.Context(),
  1255. `ALTER TABLE fave_shop_products ADD CONSTRAINT FK_shop_products_parent_id
  1256. FOREIGN KEY (parent_id) REFERENCES fave_shop_products (id) ON DELETE RESTRICT;
  1257. `); err != nil {
  1258. tx.Rollback()
  1259. wrap.MsgError(err.Error())
  1260. return
  1261. }
  1262. // Commit all changes
  1263. err = tx.Commit()
  1264. if err != nil {
  1265. wrap.MsgError(err.Error())
  1266. return
  1267. }
  1268. // Save mysql config file
  1269. err = utils.MySqlConfigWrite(wrap.DConfig+string(os.PathSeparator)+"mysql.json", pf_host, pf_port, pf_name, pf_user, pf_password)
  1270. if err != nil {
  1271. wrap.MsgError(err.Error())
  1272. return
  1273. }
  1274. // Reset robots.txt file
  1275. f, err := os.Create(wrap.DTemplate + string(os.PathSeparator) + "robots.txt")
  1276. if err == nil {
  1277. defer f.Close()
  1278. if _, err = f.WriteString("User-agent: *\r\nDisallow: /\r\n"); err != nil {
  1279. wrap.MsgError(err.Error())
  1280. return
  1281. }
  1282. }
  1283. // Create first config file
  1284. if err := wrap.ConfigSave(); err != nil {
  1285. wrap.MsgError(err.Error())
  1286. return
  1287. }
  1288. wrap.ResetCacheBlocks()
  1289. // Reload current page
  1290. wrap.Write(`window.location.reload(false);`)
  1291. })
  1292. }