-- Прямое создание таблицы city_objects
-- Выполните этот SQL в pgAdmin или psql

DROP TABLE IF EXISTS city_objects CASCADE;

CREATE TABLE city_objects (
    id SERIAL PRIMARY KEY,
    city_id INTEGER NOT NULL,
    name VARCHAR(255) NOT NULL DEFAULT '',
    model_url VARCHAR(500) NOT NULL,
    pos_x DECIMAL(15, 6) NOT NULL DEFAULT 0,
    pos_y DECIMAL(15, 6) NOT NULL DEFAULT 0,
    pos_z DECIMAL(15, 6) NOT NULL DEFAULT 0,
    rot_x DECIMAL(15, 6) NOT NULL DEFAULT 0,
    rot_y DECIMAL(15, 6) NOT NULL DEFAULT 0,
    rot_z DECIMAL(15, 6) NOT NULL DEFAULT 0,
    scale_x DECIMAL(15, 6) NOT NULL DEFAULT 1,
    scale_y DECIMAL(15, 6) NOT NULL DEFAULT 1,
    scale_z DECIMAL(15, 6) NOT NULL DEFAULT 1,
    organization_id INTEGER NOT NULL DEFAULT 2,
    rent DECIMAL(10, 2) NOT NULL DEFAULT 0,
    tax DECIMAL(10, 2) NOT NULL DEFAULT 0,
    collidable BOOLEAN NOT NULL DEFAULT false,
    interior_id INTEGER NOT NULL DEFAULT 101,
    textures VARCHAR(500) NOT NULL DEFAULT '-'
);

CREATE INDEX idx_city_objects_city_id ON city_objects(city_id);
CREATE INDEX idx_city_objects_organization_id ON city_objects(organization_id);
CREATE INDEX idx_city_objects_interior_id ON city_objects(interior_id);
CREATE INDEX idx_city_objects_position ON city_objects(pos_x, pos_y, pos_z);
CREATE INDEX idx_city_objects_collidable ON city_objects(collidable);
