mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopdb: add ability to track manual migrations
This commit is contained in:
parent
4f5c806ba5
commit
c650cdc8a8
11 changed files with 151 additions and 0 deletions
45
loopdb/sqlc/migration_tracker.sql.go
Normal file
45
loopdb/sqlc/migration_tracker.sql.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// source: migration_tracker.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const getMigration = `-- name: GetMigration :one
|
||||
SELECT
|
||||
migration_id,
|
||||
migration_ts
|
||||
FROM
|
||||
migration_tracker
|
||||
WHERE
|
||||
migration_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetMigration(ctx context.Context, migrationID string) (MigrationTracker, error) {
|
||||
row := q.db.QueryRowContext(ctx, getMigration, migrationID)
|
||||
var i MigrationTracker
|
||||
err := row.Scan(&i.MigrationID, &i.MigrationTs)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const insertMigration = `-- name: InsertMigration :exec
|
||||
INSERT INTO migration_tracker (
|
||||
migration_id,
|
||||
migration_ts
|
||||
) VALUES ($1, $2)
|
||||
`
|
||||
|
||||
type InsertMigrationParams struct {
|
||||
MigrationID string
|
||||
MigrationTs sql.NullTime
|
||||
}
|
||||
|
||||
func (q *Queries) InsertMigration(ctx context.Context, arg InsertMigrationParams) error {
|
||||
_, err := q.db.ExecContext(ctx, insertMigration, arg.MigrationID, arg.MigrationTs)
|
||||
return err
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue