-- --------------------------------------------------------
-- Server OS:                    Win64
-- HeidiSQL Version:             12.5.0.6677
-- --------------------------------------------------------



-- Dumping database structure for post_site
CREATE DATABASE IF NOT EXISTS `post_site` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */;
USE `post_site`;

-- Dumping structure for table post_site.account
CREATE TABLE IF NOT EXISTS `account` (
  `ID` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID',
  `email` varchar(20) NOT NULL,
  `username` varchar(20) NOT NULL COMMENT 'User name',
  `password` varchar(150) NOT NULL COMMENT 'User password',
  `image` varchar(100) NOT NULL DEFAULT '0' COMMENT 'User profile picture',
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Dumping data for table post_site.account: ~4 rows (approximately)
INSERT INTO `account` (`ID`, `email`, `username`, `password`, `image`) VALUES
	(10, 'admin1@1', 'admin1', '$argon2id$v=19$m=65536,t=4,p=1$WVJzczVMekRuQkRCdjBKRw$iSilBkHf+O0IRQP4qMEpYVcVS7XzuiGArpob/WLkEyc', 'default.png'),
	(11, 'admin2@2', 'admin2', '$argon2id$v=19$m=65536,t=4,p=1$SWczZzhlcGZqNWJ6d0xBaQ$lJNKIMeAXTkCXvRws8dZ0WwbFXihF7FcXtLUYkG+X7w', 'default.png'),
	(80, 'rally1@smthin.aa', 'rally1', '$argon2id$v=19$m=65536,t=4,p=1$aExmQ1hFQUNMTHZpeWJ3YQ$KFUN9uvJH21bEf1tV08DzCo1drJu48e783qXzjG6XWA', '1780299518_482ffe2c4ba4f1a3c160.webp'),
	(81, 'rally2@smthin.aa', 'rally2', '$argon2id$v=19$m=65536,t=4,p=1$OGxha2FVTEI2Tlh3RnI2Mw$q9uOxZkdZRi03uZBQ3bhJKbNJ+ImJBidy/BerU/h144', '1780300323_0253dc877cd44eefe707.jpg');

-- Dumping structure for function post_site.account_deletion
DELIMITER //
CREATE FUNCTION `account_deletion`(`request_id` INT
) RETURNS varchar(100) CHARSET utf8 COLLATE utf8_unicode_ci
BEGIN
DECLARE image_a VARCHAR(100);
SET image_a = (SELECT image FROM account WHERE ID=request_id);
DELETE FROM comments WHERE comment_account_id=request_id;
DELETE FROM comments WHERE post_account_id=request_id;
DELETE FROM posts WHERE account_id=request_id;
DELETE FROM account WHERE ID=request_id;
RETURN(image_a);
END//
DELIMITER ;

-- Dumping structure for function post_site.check_user
DELIMITER //
CREATE FUNCTION `check_user`(`mail` VARCHAR(50)
) RETURNS varchar(40) CHARSET utf8 COLLATE utf8_unicode_ci
    SQL SECURITY INVOKER
BEGIN #pārbauda vai lietotājvārds, epasts un telefona nummurs nav jau saglabāts datubāzē
DECLARE email_result VARCHAR(30);
DECLARE result VARCHAR(30);

SET email_result = (SELECT if (EXISTS (SELECT email FROM account WHERE email = mail), "email", "0"));

SET result = CONCAT_WS(",",email_result);
RETURN (result);
END//
DELIMITER ;

-- Dumping structure for table post_site.comments
CREATE TABLE IF NOT EXISTS `comments` (
  `ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `comment_account_id` int(11) NOT NULL,
  `post_account_id` int(11) NOT NULL,
  `post_id` int(11) NOT NULL,
  `comment` varchar(1000) NOT NULL DEFAULT '',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=108 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Dumping data for table post_site.comments: ~2 rows (approximately)
INSERT INTO `comments` (`ID`, `comment_account_id`, `post_account_id`, `post_id`, `comment`, `created_at`, `updated_at`) VALUES
	(106, 81, 80, 7040, 'its simply peak', '2026-06-01 07:52:11', NULL),
	(107, 81, 80, 7129, 'simply peak', '2026-06-01 08:44:42', NULL);

-- Dumping structure for function post_site.create_account
DELIMITER //
CREATE FUNCTION `create_account`(`email` VARCHAR(50),
	`username` VARCHAR(50),
	`password` VARCHAR(150),
	`image` VARCHAR(50)
) RETURNS varchar(60) CHARSET utf8 COLLATE utf8_unicode_ci
    SQL SECURITY INVOKER
BEGIN #izveido lietotāja kontu, izmantojot lietotājvārdu, epastu, telefona numuru, paroli un check_user funkciju
DECLARE account_exists VARCHAR(60);
DECLARE account_id int;

set account_exists = (SELECT check_user(email));

if account_exists = "0" then
INSERT INTO account (email, username, PASSWORD, image) VALUE (email, username, PASSWORD, image);
SET account_id = (SELECT id FROM account o WHERE o.email=email);
RETURN(CONCAT(account_id,",account_created"));
ELSE 
RETURN("useless,account_exists");
END if;

END//
DELIMITER ;

-- Dumping structure for function post_site.create_comment
DELIMITER //
CREATE FUNCTION `create_comment`(`post_id` INT,
	`comment` VARCHAR(500),
	`commenter_id` INT
) RETURNS varchar(20) CHARSET utf8 COLLATE utf8_unicode_ci
BEGIN
DECLARE post_account_id INT;
DECLARE retun_id INT;
set post_account_id = (select account_id from posts where id=post_id);
INSERT INTO comments (comment_account_id, post_account_id, post_id, comment) value (commenter_id, post_account_id, post_id, COMMENT);

RETURN(CONCAT("success,",LAST_INSERT_ID()));
END//
DELIMITER ;

-- Dumping structure for function post_site.delete_comment
DELIMITER //
CREATE FUNCTION `delete_comment`(`comment_id` INT,
	`account_id` INT
) RETURNS varchar(20) CHARSET utf8 COLLATE utf8_unicode_ci
BEGIN

if((SELECT comment_account_id FROM comments WHERE id = comment_id) = account_id OR account_id = 10 OR account_id = 11) then
DELETE FROM comments WHERE id = comment_id;
RETURN("success");
ELSE
RETURN("nah");
END if;
END//
DELIMITER ;

-- Dumping structure for function post_site.edit_comment
DELIMITER //
CREATE FUNCTION `edit_comment`(`comment_id` INT,
	`account_id` INT,
	`comment_edit` VARCHAR(500)
) RETURNS varchar(20) CHARSET utf8 COLLATE utf8_unicode_ci
BEGIN


if((SELECT comment_account_id FROM comments WHERE id = comment_id) = account_id) then
UPDATE comments SET comment = comment_edit where id = comment_id; 
RETURN("success");
ELSE
RETURN("nah");
END if;

END//
DELIMITER ;

-- Dumping structure for function post_site.edit_post
DELIMITER //
CREATE FUNCTION `edit_post`(`post_id` INT,
	`edit_id` INT,
	`image_updated` INT,
	`title1` VARCHAR(50),
	`price1` VARCHAR(50),
	`description1` VARCHAR(5000),
	`image1` VARCHAR(1000),
	`tags_id1` VARCHAR(30)
) RETURNS varchar(20) CHARSET utf8 COLLATE utf8_unicode_ci
begin
DECLARE poster_id INT;
SET poster_id = (SELECT account_id from posts WHERE id = post_id);
if image_updated = 1 and edit_id = poster_id then
UPDATE posts
SET title = title1,
    price = price1,
    DESCRIPTION = DESCRIPTION1,
    image = image1,
    updated_at = NOW(),
    tags_id = tags_id1
WHERE id = post_id;
RETURN("success");

ELSEIF edit_id = poster_id then
UPDATE posts
SET title = title1,
    price = price1,
    DESCRIPTION = DESCRIPTION1,
    updated_at = NOW(),
    tags_id = tags_id1
WHERE id = post_id;
RETURN("success");
ELSE RETURN("nuh");
END if;
end//
DELIMITER ;

-- Dumping structure for function post_site.fetch_comments
DELIMITER //
CREATE FUNCTION `fetch_comments`(`fetch_post_id` INT,
	`last_id` INT
) RETURNS varchar(100) CHARSET utf8 COLLATE utf8_unicode_ci
    COMMENT 'ea'
BEGIN #change this to less requests, forgor abt select something,something
DECLARE COMMENT_contents VARCHAR(100);
DECLARE commenter_id INT;
DECLARE commenter_username VARCHAR(30);
DECLARE commenter_image varchar(50);
DECLARE comment_id INT;
DECLARE comment_date TIMESTAMP;
SET COMMENT_contents = (
        SELECT COMMENT
        FROM comments
        where post_id = fetch_post_id
            AND id > last_id
        LIMIT 1
    );
SET commenter_id = (
        SELECT comment_account_id
        FROM comments
        where post_id = fetch_post_id
            AND id > last_id
        LIMIT 1
    );
SET commenter_username = (
        SELECT username
        FROM account
        WHERE id = commenter_id
    );
SET commenter_image = (
        SELECT image
        FROM account
        WHERE id = commenter_id
    );
SET comment_id = (
        SELECT id
        FROM comments
        where post_id = fetch_post_id
            AND id > last_id
        LIMIT 1
    );
SET comment_date = (
		  SELECT created_at
		  FROM comments
		  WHERE post_id = fetch_post_id
		  LIMIT 1
	  );
RETURN(
    CONCAT(
    	  "success,",
        commenter_image,
        ",",
        commenter_username,
        ",",
        COMMENT_contents,
        ",",
        comment_id,
        ",",
        comment_date,
        ",",
        commenter_id
    )
);
END//
DELIMITER ;

-- Dumping structure for function post_site.login
DELIMITER //
CREATE FUNCTION `login`(`name` VARCHAR(50),
	`pass` VARCHAR(50)
) RETURNS varchar(100) CHARSET utf8 COLLATE utf8_unicode_ci
    SQL SECURITY INVOKER
    COMMENT 'in short, checks if its username or email, then has 2 pretty much same processes to insert data into account, one for email and one for username'
BEGIN
DECLARE USER VARCHAR(20);
DECLARE username_request VARCHAR(20);
DECLARE pfp VARCHAR(50);
DECLARE user_id INT;
if LOCATE("@", NAME) = 0 THEN #pārbauda vai ievadītie dati ir ēpasts vai lietottājvārds, meklējot @ simbolu
SET USER = "username"; 
SET username_request = NAME;
SET pfp = (
		  SELECT image
		  FROM account
		  WHERE username = NAME
	 );
SET user_id = (
        SELECT id
        FROM account
        WHERE username = NAME
    );
ELSE
SET USER = "email";
SET username_request = (
		  SELECT username
		  FROM account
		  WHERE email = NAME
	 );
SET pfp = (
		  SELECT image
		  FROM account
		  WHERE email = NAME
	 );
SET user_id = (
        SELECT id
        FROM account
        WHERE email = NAME
    );
END if;
if USER = "username" THEN if (
    SELECT PASSWORD
    FROM account
    WHERE username = name
) = pass THEN if EXISTS(
    SELECT account_id
    FROM USER
    WHERE account_id = user_id
) THEN
UPDATE USER
SET TIME = NOW()
WHERE account_id = user_id;
ELSE
INSERT INTO USER (account_id, TIME)
VALUES (user_id, NOW());
END if;
RETURN(CONCAT (user_id, ",", username_request, ",", pfp, ",loged in successfully"));
ELSE RETURN("incorrect username or password");
END if;
ELSEIF (
    SELECT PASSWORD
    FROM account
    WHERE email = name
) = pass THEN if EXISTS(
    SELECT account_id
    FROM USER
    WHERE account_id = user_id
) THEN
UPDATE USER
SET TIME = NOW();
ELSE
INSERT INTO USER (account_id, TIME)
VALUES (user_id, NOW());
END if;
RETURN(user_id, ",", username_request, ",", pfp, ",loged in successfully");
ELSE RETURN("incorrect email or password");
END if;
END//
DELIMITER ;

-- Dumping structure for table post_site.posts
CREATE TABLE IF NOT EXISTS `posts` (
  `ID` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `account_id` int(11) NOT NULL,
  `title` varchar(50) NOT NULL,
  `price` varchar(10) NOT NULL,
  `description` varchar(10000) NOT NULL,
  `image` varchar(5000) NOT NULL DEFAULT '',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL,
  `tags_id` varchar(50) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7130 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Dumping data for table post_site.posts: ~102 rows (approximately)
INSERT INTO `posts` (`ID`, `account_id`, `title`, `price`, `description`, `image`, `created_at`, `updated_at`, `tags_id`) VALUES
	(7023, 81, 'Puķes roza', '10', '{"ops":[{"insert":"roza\\n"}]}', '[{"filename":"1780301718_fcc5650487b0ddf2974c.png"}]', '2026-06-01 05:15:18', NULL, '["12"]'),
	(7024, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7025, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7026, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7027, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7028, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7029, 81, 'big dino', '1', '{"ops":[{"insert":"roar\\n"}]}', '[{"filename":"1780300499_dccd59c965d402107506.png"}]', '2026-06-01 04:54:59', NULL, '[]'),
	(7030, 81, 'Puķes roza', '10', '{"ops":[{"insert":"roza\\n"}]}', '[{"filename":"1780301718_fcc5650487b0ddf2974c.png"}]', '2026-06-01 05:15:18', NULL, '["12"]'),
	(7031, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7032, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7033, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7034, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7035, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7036, 81, 'big dino', '1', '{"ops":[{"insert":"roar\\n"}]}', '[{"filename":"1780300499_dccd59c965d402107506.png"}]', '2026-06-01 04:54:59', NULL, '[]'),
	(7037, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7038, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7039, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7040, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7041, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7042, 81, 'Puķes roza', '10', '{"ops":[{"insert":"roza\\n"}]}', '[{"filename":"1780301718_fcc5650487b0ddf2974c.png"}]', '2026-06-01 05:15:18', NULL, '["12"]'),
	(7043, 81, 'big dino', '1', '{"ops":[{"insert":"roar\\n"}]}', '[{"filename":"1780300499_dccd59c965d402107506.png"}]', '2026-06-01 04:54:59', NULL, '[]'),
	(7044, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7045, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7046, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7047, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7048, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7049, 81, 'Puķes roza', '10', '{"ops":[{"insert":"roza\\n"}]}', '[{"filename":"1780301718_fcc5650487b0ddf2974c.png"}]', '2026-06-01 05:15:18', NULL, '["12"]'),
	(7050, 80, 'The Radiant lubovka', '900000', '{"ops":[{"attributes":{"size":"huge"},"insert":"LIVING SHIP"},{"insert":"\\n\\nDamage: 342"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Shield: 225"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Hyperdrive range: 192"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Manoeuvrability: 229"},{"attributes":{"list":"bullet"},"insert":"\\n"}]}', '[{"filename":"1780300166_6e3a448124739a29038a.png"},{"filename":"1780300166_7a700efe8d4496a8b403.png"},{"filename":"1780300166_32ddbb8c2d3b9e0cb29d.png"}]', '2026-06-01 08:17:36', NULL, '["6"]'),
	(7051, 80, 'v-Fire', '900000', '{"ops":[{"attributes":{"size":"huge"},"insert":"SENTINEL SHIP"},{"insert":"\\n\\nDamage: 396"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Shield: 276"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Hyperdrive range: 1164"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Manoeuvrability: 1147 "},{"attributes":{"list":"bullet"},"insert":"\\n"}]}', '[{"filename":"1780300276_1f139b912744c49c1a5d.png"},{"filename":"1780300276_c91450c927af8bb349a1.png"},{"filename":"1780300276_346470b3472736caedf0.png"}]', '2026-06-01 08:18:01', NULL, '["5"]'),
	(7052, 80, '\'SS-8 Ginokuch\'', '90000000', '{"ops":[{"attributes":{"size":"huge"},"insert":"PIRATE FREIGHTER SHIP"},{"insert":"\\n\\nRace: Korvax"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Fleet size: 6"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Class: Freighter // S:28+16"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Hyperdrive range: 1894"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Storage: 28 "},{"attributes":{"list":"bullet"},"insert":"\\n"}]}', '[{"filename":"1780299878_d691aff807e9f4175781.png"},{"filename":"1780299878_19df402eecb325123963.png"},{"filename":"1780299878_ebadd1c929c052d37b07.png"},{"filename":"1780299878_e82db7d25c7b31b2c487.png"},{"filename":"1780299878_de1ff2f23cb305924bb8.png"},{"filename":"1780299878_f6d1e8db4c801bff26f4.png"},{"filename":"1780299878_a7ba1051b8b2d4b57cdf.png"}]', '2026-06-01 08:18:12', NULL, '["7"]'),
	(7053, 81, 'Putns', '100', '{"ops":[{"insert":"putns\\n"}]}', '[{"filename":"1780302013_ef5a2eeef32987d37b5b.png"}]', '2026-06-01 05:20:13', NULL, '["15"]'),
	(7054, 81, 'Bilde', '1', '{"ops":[{"insert":"bilde\\n"}]}', '[{"filename":"1780302031_96e757618b10ee9ff345.png"}]', '2026-06-01 05:20:31', NULL, '[]'),
	(7057, 81, 'big dino', '1', '{"ops":[{"insert":"roar\\n"}]}', '[{"filename":"1780300499_dccd59c965d402107506.png"}]', '2026-06-01 04:54:59', NULL, '[]'),
	(7058, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7059, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7060, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7061, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7062, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7063, 81, 'Puķes roza', '10', '{"ops":[{"insert":"roza\\n"}]}', '[{"filename":"1780301718_fcc5650487b0ddf2974c.png"}]', '2026-06-01 05:15:18', NULL, '["12"]'),
	(7064, 81, 'big dino', '1', '{"ops":[{"insert":"roar\\n"}]}', '[{"filename":"1780300499_dccd59c965d402107506.png"}]', '2026-06-01 04:54:59', NULL, '[]'),
	(7065, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7066, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7067, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7068, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7069, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7070, 81, 'Puķes roza', '10', '{"ops":[{"insert":"roza\\n"}]}', '[{"filename":"1780301718_fcc5650487b0ddf2974c.png"}]', '2026-06-01 05:15:18', NULL, '["12"]'),
	(7071, 81, 'big dino', '1', '{"ops":[{"insert":"roar\\n"}]}', '[{"filename":"1780300499_dccd59c965d402107506.png"}]', '2026-06-01 04:54:59', NULL, '[]'),
	(7072, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7073, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7074, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7075, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7076, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7077, 81, 'Puķes roza', '10', '{"ops":[{"insert":"roza\\n"}]}', '[{"filename":"1780301718_fcc5650487b0ddf2974c.png"}]', '2026-06-01 05:15:18', NULL, '["12"]'),
	(7078, 81, 'big dino', '1', '{"ops":[{"insert":"roar\\n"}]}', '[{"filename":"1780300499_dccd59c965d402107506.png"}]', '2026-06-01 04:54:59', NULL, '[]'),
	(7079, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7080, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7081, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7082, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7083, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7084, 81, 'Puķes roza', '10', '{"ops":[{"insert":"roza\\n"}]}', '[{"filename":"1780301718_fcc5650487b0ddf2974c.png"}]', '2026-06-01 05:15:18', NULL, '["12"]'),
	(7085, 81, 'big dino', '1', '{"ops":[{"insert":"roar\\n"}]}', '[{"filename":"1780300499_dccd59c965d402107506.png"}]', '2026-06-01 04:54:59', NULL, '[]'),
	(7086, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7087, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7088, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7089, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7090, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7091, 81, 'Puķes roza', '10', '{"ops":[{"insert":"roza\\n"}]}', '[{"filename":"1780301718_fcc5650487b0ddf2974c.png"}]', '2026-06-01 05:15:18', NULL, '["12"]'),
	(7092, 81, 'big dino', '1', '{"ops":[{"insert":"roar\\n"}]}', '[{"filename":"1780300499_dccd59c965d402107506.png"}]', '2026-06-01 04:54:59', NULL, '[]'),
	(7093, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7094, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7095, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7096, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7097, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7098, 81, 'Puķes roza', '10', '{"ops":[{"insert":"roza\\n"}]}', '[{"filename":"1780301718_fcc5650487b0ddf2974c.png"}]', '2026-06-01 05:15:18', NULL, '["12"]'),
	(7099, 81, 'big dino', '1', '{"ops":[{"insert":"roar\\n"}]}', '[{"filename":"1780300499_dccd59c965d402107506.png"}]', '2026-06-01 04:54:59', NULL, '[]'),
	(7100, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7101, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7102, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7103, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7104, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7105, 81, 'Puķes roza', '10', '{"ops":[{"insert":"roza\\n"}]}', '[{"filename":"1780301718_fcc5650487b0ddf2974c.png"}]', '2026-06-01 05:15:18', NULL, '["12"]'),
	(7106, 81, 'big dino', '1', '{"ops":[{"insert":"roar\\n"}]}', '[{"filename":"1780300499_dccd59c965d402107506.png"}]', '2026-06-01 04:54:59', NULL, '[]'),
	(7107, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7108, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7109, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7110, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7111, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7112, 81, 'Puķes roza', '10', '{"ops":[{"insert":"roza\\n"}]}', '[{"filename":"1780301718_fcc5650487b0ddf2974c.png"}]', '2026-06-01 05:15:18', NULL, '["12"]'),
	(7113, 81, 'big dino', '1', '{"ops":[{"insert":"roar\\n"}]}', '[{"filename":"1780300499_dccd59c965d402107506.png"}]', '2026-06-01 04:54:59', NULL, '[]'),
	(7114, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7115, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7116, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7117, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7118, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7119, 81, 'Puķes roza', '10', '{"ops":[{"insert":"roza\\n"}]}', '[{"filename":"1780301718_fcc5650487b0ddf2974c.png"}]', '2026-06-01 05:15:18', NULL, '["12"]'),
	(7120, 81, 'big dino', '1', '{"ops":[{"insert":"roar\\n"}]}', '[{"filename":"1780300499_dccd59c965d402107506.png"}]', '2026-06-01 04:54:59', NULL, '[]'),
	(7121, 81, 'Puķes Krāsainas', '10', '{"ops":[{"insert":"Krāsainas\\n"}]}', '[{"filename":"1780301130_40b0c9d02a191ca2a1f0.png"}]', '2026-06-01 05:05:30', NULL, '["12"]'),
	(7122, 81, 'Puķes violetas', '10', '{"ops":[{"insert":"violetas\\n"}]}', '[{"filename":"1780301149_13ac2a288cdfcdefeecb.png"}]', '2026-06-01 05:05:49', NULL, '["12"]'),
	(7123, 81, 'Mašīna Kia', '10000', '{"ops":[{"insert":"Kia\\n"}]}', '[{"filename":"1780301247_29df735dbac53de041b3.png"}]', '2026-06-01 05:07:27', NULL, '["13"]'),
	(7124, 81, 'Lotus Emira', '1000', '{"ops":[{"insert":"Lotus Emira\\n"}]}', '[{"filename":"1780301649_83979cee30ef84d79d55.png"}]', '2026-06-01 05:14:09', NULL, '["14"]'),
	(7125, 81, 'Puķes baltas', '10', '{"ops":[{"insert":"Baltas\\n"}]}', '[{"filename":"1780301701_71984cd5eef8fc49dbaf.png"}]', '2026-06-01 05:15:01', NULL, '["12"]'),
	(7127, 80, 'The Radiant lubovka', '900000', '{"ops":[{"attributes":{"size":"huge"},"insert":"LIVING SHIP"},{"insert":"\\n\\nDamage: 342"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Shield: 225"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Hyperdrive range: 192"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Manoeuvrability: 229"},{"attributes":{"list":"bullet"},"insert":"\\n"}]}', '[{"filename":"1780300166_6e3a448124739a29038a.png"},{"filename":"1780300166_7a700efe8d4496a8b403.png"},{"filename":"1780300166_32ddbb8c2d3b9e0cb29d.png"}]', '2026-06-01 08:17:36', NULL, '["6"]'),
	(7128, 80, 'v-Fire', '900000', '{"ops":[{"attributes":{"size":"huge"},"insert":"SENTINEL SHIP"},{"insert":"\\n\\nDamage: 396"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Shield: 276"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Hyperdrive range: 1164"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Manoeuvrability: 1147 "},{"attributes":{"list":"bullet"},"insert":"\\n"}]}', '[{"filename":"1780300276_1f139b912744c49c1a5d.png"},{"filename":"1780300276_c91450c927af8bb349a1.png"},{"filename":"1780300276_346470b3472736caedf0.png"}]', '2026-06-01 08:18:01', NULL, '["5"]'),
	(7129, 80, '\'SS-8 Ginokuch\'', '90000000', '{"ops":[{"attributes":{"size":"huge"},"insert":"PIRATE FREIGHTER SHIP"},{"insert":"\\n\\nRace: Korvax"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Fleet size: 6"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Class: Freighter // S:28+16"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Hyperdrive range: 1894"},{"attributes":{"list":"bullet"},"insert":"\\n"},{"insert":"Storage: 28 "},{"attributes":{"list":"bullet"},"insert":"\\n"}]}', '[{"filename":"1780299878_d691aff807e9f4175781.png"},{"filename":"1780299878_19df402eecb325123963.png"},{"filename":"1780299878_ebadd1c929c052d37b07.png"},{"filename":"1780299878_e82db7d25c7b31b2c487.png"},{"filename":"1780299878_de1ff2f23cb305924bb8.png"},{"filename":"1780299878_f6d1e8db4c801bff26f4.png"},{"filename":"1780299878_a7ba1051b8b2d4b57cdf.png"}]', '2026-06-01 08:18:12', NULL, '["7"]');

-- Dumping structure for function post_site.post_deletion
DELIMITER //
CREATE FUNCTION `post_deletion`(`post_id` INT,
	`request_id` INT
) RETURNS varchar(1000) CHARSET utf8 COLLATE utf8_unicode_ci
BEGIN
DECLARE result VARCHAR(1000);
if request_id = (SELECT account_id FROM posts WHERE Id=post_id) OR request_id = 10 OR request_id = 11 then
SET result = (SELECT image FROM posts WHERE id = post_id);
DELETE FROM posts WHERE id=post_id;
RETURN(CONCAT("success,", result));
ELSE 
RETURN("nuh uh");
END if;
END//
DELIMITER ;

-- Dumping structure for table post_site.tags
CREATE TABLE IF NOT EXISTS `tags` (
  `ID` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `list` varchar(20) NOT NULL,
  `tags` varchar(20) NOT NULL DEFAULT '',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Dumping data for table post_site.tags: ~13 rows (approximately)
INSERT INTO `tags` (`ID`, `list`, `tags`) VALUES
	(1, 'Mebeles', 'Krēsli'),
	(2, 'Mebeles', 'Gultas'),
	(3, 'Malka', 'Egle'),
	(4, 'Malka', 'Bērzs'),
	(5, 'Ship', 'Sentinel'),
	(6, 'Ship', 'Living'),
	(7, 'Ship', 'Freighter'),
	(8, 'Braucamrīki', 'Ritenis'),
	(9, 'Braucamrīki', 'Mašīna'),
	(10, 'Braucamrīki', 'Skūteris'),
	(12, 'Augi', 'Puķes'),
	(13, 'Masīnas', 'Kia'),
	(14, 'Masīnas', 'Lotus Emira'),
	(15, 'Dzīvnieki', 'Putns');

-- Dumping structure for function post_site.timeout
DELIMITER //
CREATE FUNCTION `timeout`(`user_id` INT
) RETURNS varchar(20) CHARSET utf8 COLLATE utf8_unicode_ci
    SQL SECURITY INVOKER
    COMMENT 'maybe'
BEGIN


#when user logs in or refreshes, check the timeout time, if the time is past timeout time, log out, if the time is before
#timeout time, refresh the timout time
#select TIME FROM user WHERE account_id = user_id;
RETURN("fraewga");
END


#when user logs in or refreshes, check the timeout time, if the time is past timeout time, log out, if the time is before
#timeout time, refresh the timout time//
DELIMITER ;

-- Dumping structure for table post_site.user
CREATE TABLE IF NOT EXISTS `user` (
  `ID` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Login ID',
  `account_id` int(10) unsigned NOT NULL COMMENT 'User id',
  `time` datetime NOT NULL COMMENT 'Time to work',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=60 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- Dumping data for table post_site.user: ~0 rows (approximately)

