# Настройка и установка PostgreSQL

Скачать последнюю версию ПГадмин тут - <https://www.enterprisedb.com/downloads/postgres-postgresql-downloads>

<figure><img src="/files/0SxCYoO5dYE6R9AaNABs" alt=""><figcaption></figcaption></figure>

При установке - запрашивает пароль, пароль надо запомнить и сохранить, это ваш доступ к базе.

\ <br>

<figure><img src="/files/ZN7Xz6kAHH14qUHa9Xl9" alt=""><figcaption></figcaption></figure>

при установке, уберите чекбокс Stack Builder\ <br>

<figure><img src="/files/12xGI658L6xgvyhx7koL" alt=""><figcaption></figcaption></figure>

ВАЖНО!!!!!

При установке - запрашивает пароль, пароль надо запомнить и сохранить, это ваш доступ к базе.<br>

<figure><img src="/files/sayviUJE8X4ZhLpn8pm5" alt=""><figcaption></figcaption></figure>

Если у вас нету спец порта, оставьте дефолт значение.\ <br>

<figure><img src="/files/3WtDAVNYNdQRqlFDmFiW" alt=""><figcaption></figcaption></figure>

Опционально!

Смените дефолт локацию на ru-Ru (Москва)

\
После установки базы данных открыть консоль:\
\
![](/files/MKg84ysoYlIb8w7hVPNh)

В открывшимся окне ввести:

```sql
create table public.profiles_old
(
    name            varchar(150),
    path            varchar(255),
    cookies         integer     default 0                     not null,
    proxy           varchar(255),
    login_yandex    varchar(50),
    number_of_uses  integer     default 0,
    now_in_work     timestamp,
    last_use        timestamp   default now()                 not null,
    status          varchar(50) default ''::character varying not null,
    create_date     timestamp   default now()                 not null,
    useragent       varchar(255),
    device          varchar(50),
    group_name      varchar(50),
    id              integer generated by default as identity
        constraint profiles_pkey
            primary key,
    warming_repeat  integer     default 0                     not null,
    geo_name        varchar(64),
    warming_counter integer     default 0,
    last_warm       timestamp,
    geo_google      varchar(64),
    end_of_work     timestamp,
    last_promotion  timestamp,
    used_domains    text        default ''::text              not null,
    cookies_text    text,
    local_storage   text,
    fingerprint     text,
    geo_coord       varchar(50),
    yandex_account  bigint
);

comment on column public.profiles_old.geo_name is 'Гео (название)';

comment on column public.profiles_old.geo_google is 'Гео (google)';

alter table public.profiles_old
    owner to postgres;

create index profiles_device_index
    on public.profiles_old (device);

create index profiles_path_index
    on public.profiles_old (path);

create index profiles_status_index
    on public.profiles_old (status);

create index profiles_useragent_index
    on public.profiles_old (useragent);

create index profiles_group_name_index
    on public.profiles_old (group_name);

create index profiles_group_index
    on public.profiles_old (group_name);

create table public.accounts
(
    id            serial
        constraint id
            primary key,
    login         varchar(50)             not null,
    password      varchar(50),
    recovery_code varchar(50),
    cookies       text,
    phone         varchar(50),
    first_name    varchar(100),
    last_name     varchar(100),
    code_question varchar(100),
    stolen        boolean,
    status        varchar(50),
    date_create   timestamp default now() not null,
    site          varchar(30),
    constraint accounts_pk
        unique (login, site)
);

comment on column public.accounts.login is 'Логин';

comment on column public.accounts.password is 'Пароль';

comment on column public.accounts.recovery_code is 'Кодовое слово';

comment on column public.accounts.cookies is 'COOKIES';

comment on column public.accounts.phone is 'Телефон';

comment on column public.accounts.first_name is 'Имя';

comment on column public.accounts.last_name is 'Фамилия';

comment on column public.accounts.code_question is 'Вопрос кодового слова';

comment on column public.accounts.stolen is 'Украденый';

comment on column public.accounts.status is 'Статус';

comment on column public.accounts.date_create is 'Дата создания';

alter table public.accounts
    owner to postgres;

create unique index accounts_login_uindex
    on public.accounts (login);

create table public.dzen
(
    id            serial
        constraint dzen_pk
            primary key,
    login         varchar(50),
    psevdonim     varchar(50),
    url_channel   varchar(255),
    dashboard     varchar(255),
    article_count integer   default 0     not null,
    status        varchar(50),
    date_create   timestamp default now() not null
);

comment on column public.dzen.login is 'Логин';

comment on column public.dzen.psevdonim is 'Псевдоним для профиля';

comment on column public.dzen.url_channel is 'Ссылка на канал';

comment on column public.dzen.dashboard is 'Панель управления каналом';

comment on column public.dzen.article_count is 'Количество статей';

comment on column public.dzen.status is 'Статус';

comment on column public.dzen.date_create is 'Дата создания';

alter table public.dzen
    owner to postgres;

create table public.tasks
(
    id          serial
        constraint tasks_pk
            primary key,
    project     varchar(64),
    query       varchar(255),
    target      text,
    "limit"     integer   default 1 not null,
    used        integer   default 0 not null,
    success     integer   default 0 not null,
    failed      integer   default 0 not null,
    last_used   timestamp,
    create_date timestamp default now(),
    soft        varchar(30),
    geo         varchar(32)
);

alter table public.tasks
    owner to postgres;

create index tasks_geo_index
    on public.tasks (geo);

create index tasks_project_index
    on public.tasks (project);

create index tasks_soft_index
    on public.tasks (soft);

create table public.marketplaces
(
    id   serial
        constraint marketplaces_pk
            primary key,
    type varchar(30)
);

alter table public.marketplaces
    owner to postgres;

create table public.dzen_articles
(
    id     serial
        constraint dzen_articles_pk
            primary key,
    chanel integer
        constraint dzen_articles_dzen_id_fk
            references public.dzen,
    title  varchar(128),
    url    varchar(255)
);

alter table public.dzen_articles
    owner to postgres;

create table public.test
(
    id serial
        constraint test_pk
            primary key,
    x  integer
);

alter table public.test
    owner to postgres;

create table public.uses
(
    profile bigint,
    task    bigint
        constraint uses_tasks_id_fk
            references public.tasks,
    project varchar(128),
    date    timestamp default CURRENT_TIMESTAMP not null
);

alter table public.uses
    owner to postgres;

create index uses_profile_index
    on public.uses (profile);

create index uses_project_index
    on public.uses (project);

create table public.fingerprints
(
    text text,
    hash varchar(32)
        constraint fingerprints_pk_2
            unique
);

alter table public.fingerprints
    owner to postgres;

create table public.profiles_data
(
    id            bigint
        constraint profiles_data_profiles_id_fk
            references public.profiles_old
            on delete cascade,
    cookies       text,
    local_storage text,
    fingerprint   text
);

alter table public.profiles_data
    owner to postgres;

create table public.profiles
(
    id              integer generated by default as identity
        constraint profiles_pkey1
            primary key,
    name            varchar(150),
    group_name      varchar(50),
    path            varchar(255) default ''::character varying,
    cookies         integer      default 0                     not null,
    proxy           varchar(255),
    status          varchar(50)  default ''::character varying not null,
    warming_counter integer      default 0,
    number_of_uses  integer      default 0,
    warming_repeat  integer      default 0                     not null,
    now_in_work     timestamp,
    last_use        timestamp    default now()                 not null,
    create_date     timestamp    default now()                 not null,
    last_warm       timestamp,
    end_of_work     timestamp,
    last_promotion  timestamp,
    useragent       varchar(255),
    device          varchar(50),
    geo_name        varchar(64)  default ''::character varying,
    geo_coord       varchar(50)  default ''::character varying,
    geo_google      varchar(64)  default ''::character varying,
    login_yandex    varchar(50),
    yandex_account  bigint,
    used_domains    text         default ''::text              not null,
    cookies_text    text         default ''::text              not null,
    local_storage   text         default ''::text              not null,
    fingerprint     text         default ''::text              not null
);

alter table public.profiles
    owner to postgres;


```

Далее нажать кнопку "плей":\
![](/files/O8aGvuZ34wsmfkf4Oh4F)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.infinitysoftcombine.ru/rabota-s-programmoi/1.-ustanovka-programmy/nastroika-i-ustanovka-postgresql.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
