CREATE TABLE groups (
    id serial NOT NULL PRIMARY KEY,
    name text,
    is_admin boolean DEFAULT false NOT NULL,
    is_vip boolean DEFAULT false NOT NULL,
    multiplier numeric DEFAULT 1 NOT NULL,
    sale double precision DEFAULT 1 NOT NULL,
    max_multigen integer DEFAULT 2 NOT NULL,
    is_tester boolean DEFAULT false NOT NULL,
    max_waifus integer DEFAULT 3 NOT NULL
);

CREATE TABLE users (
    id int8 NOT NULL PRIMARY KEY,
    balance decimal(20,0) NOT NULL DEFAULT 0,
    name text,
    group_id int REFERENCES groups(id),
    level int DEFAULT 1,
    exp int DEFAULT 0,
    work_id int REFERENCES works(id),
    work_time timestamp DEFAULT now(),

    auto_id int DEFAULT NULL,
    business_id int DEFAULT NULL,
    maid_id int DEFAULT NULL,
    miner_id int DEFAULT NULL,

    income_time timestamp DEFAULT now(),
    btc decimal(16,6) DEFAULT 0,
    invested decimal(20, 0) DEFAULT 0,
    pair_id int8 DEFAULT NULL,
    greeting text DEFAULT 'Привет',
    donat int DEFAULT 0,
    fraction_id int DEFAULT NULL,

    money_income decimal(20, 0) DEFAULT 0,
    exp_income int DEFAULT 0,
    btc_income decimal(16, 6) DEFAULT 0,

    waifu_search_time timestamp DEFAULT now()
);
CREATE UNIQUE INDEX users_uindex ON users(id);
CREATE UNIQUE INDEX groups_uindex ON groups(id);

BEGIN TRANSACTION;
INSERT INTO groups VALUES (1, '✨Пользователь✨', false, false, 1.0, 1, 3, false, 3);
INSERT INTO groups VALUES (3, '👾Премиум🌟', false, true, 5, 0.75, 7, false, 3);
INSERT INTO groups VALUES (2, '🔮VIP🔮', false, true, 2.5, 0.9, 5, false, 3);
INSERT INTO groups VALUES (4, '💎Админ💎', true, true, 10, 0.6, 10, true, 3);
INSERT INTO groups VALUES (5, '💰🔱СОЗДАТЕЛЬ🔱💰', true, true, 20, 0.5, 10, true, 3);
INSERT INTO groups VALUES (6, '⚠Тостер⚠', false, true, 3, 0.85, 3, true, 3);
INSERT INTO groups VALUES (1488, '📚Экономист📈', false, true, 14.88, 0.6, 3, false, 3);
INSERT INTO groups VALUES (1337, '🏳‍🌈ToP GaY In ThE WorlD🏳‍🌈🌈', false, true, 13.37, 0.7, 3, false, 3);
ALTER SEQUENCE groups_id_seq RESTART WITH 8;
INSERT INTO users
VALUES (314834933, 999999999, 'scuroneko', 5, 1, 0, 1, '0001-01-01 00:00:00.000000', 5, 15, 6, 14, '0001-01-01 00:00:00.000000', 999999.000000, 0, null, 'Привет', 0, null, 0, 0, 0.000000, '0001-01-01 00:00:00.000000');
COMMIT TRANSACTION;