generated from Yandex-Practicum/go-musthave-metrics-tpl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Использование golang-migrate для миграции таблички сервера + …
…Makefile для запуска бинарников" This reverts commit dbbdbbf.
- Loading branch information
1 parent
dbbdbbf
commit 16607e0
Showing
9 changed files
with
47 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package pgsql | ||
|
||
// Создание необходимых таблиц в базе данных, для gauge и счетчиков отдельные таблички, с разным типом значения. | ||
func (p *PostgresStorage) createTables() error { | ||
_, err := p.conn.Exec(p.ctx, `CREATE TABLE IF NOT EXISTS metrics ( | ||
id SERIAL PRIMARY KEY, | ||
name VARCHAR(250) NOT NULL, | ||
type VARCHAR(50) NOT NULL, | ||
delta BIGINT NULL , | ||
value DOUBLE PRECISION NULL | ||
)`) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Создаем индекс по имени метрики | ||
_, err = p.conn.Exec(p.ctx, `CREATE INDEX IF NOT EXISTS idx_metrics_name ON metrics (name)`) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Создаем индекс по типу метрики | ||
_, err = p.conn.Exec(p.ctx, `CREATE INDEX IF NOT EXISTS idx_metrics_type ON metrics (type)`) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Создаем уникальный индекс по имени и типу метрики | ||
_, err = p.conn.Exec(p.ctx, `CREATE UNIQUE INDEX IF NOT EXISTS idx_metrics_name_type ON metrics (name, type)`) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
p.log.Debug("created table if not exists: metrics") | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.