Create jobs migrations

This commit is contained in:
2025-08-24 00:51:34 +02:00
parent 41b6bf3df6
commit 3544ecb5f7
7 changed files with 68 additions and 2 deletions

View File

@@ -2,6 +2,10 @@
cish start postgres cish start postgres
if [[ true ]]; then
true
fi
for job in v1.22.0 v1.0.0 titi; do for job in v1.22.0 v1.0.0 titi; do
cish run ../ex.sh --version=$job cish run ../ex.sh --version=$job

7
.pg_format Normal file
View File

@@ -0,0 +1,7 @@
tabs=1
function-case=1 #lowercase
keyword-case=1
type-case=1
no-space-function=1
keep-newline=1
nogrouping=1

View File

@@ -3,9 +3,11 @@ module github.com/zoriya/cish/api
go 1.24.5 go 1.24.5
require ( require (
github.com/go-git/go-git/v6 v6.0.0-20250819122726-39261590f7f3
github.com/jackc/pgx/v5 v5.7.5 github.com/jackc/pgx/v5 v5.7.5
github.com/labstack/echo/v4 v4.13.4 github.com/labstack/echo/v4 v4.13.4
github.com/ren3gadem4rm0t/github-hook-types-go v0.1.1 github.com/ren3gadem4rm0t/github-hook-types-go v0.1.1
github.com/spf13/viper v1.20.1
) )
require ( require (
@@ -18,7 +20,6 @@ require (
github.com/fsnotify/fsnotify v1.8.0 // indirect github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/go-git/gcfg/v2 v2.0.2 // indirect github.com/go-git/gcfg/v2 v2.0.2 // indirect
github.com/go-git/go-billy/v6 v6.0.0-20250627091229-31e2a16eef30 // indirect github.com/go-git/go-billy/v6 v6.0.0-20250627091229-31e2a16eef30 // indirect
github.com/go-git/go-git/v6 v6.0.0-20250819122726-39261590f7f3 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/google/go-github/v74 v74.0.0 // indirect github.com/google/go-github/v74 v74.0.0 // indirect
@@ -39,7 +40,6 @@ require (
github.com/spf13/afero v1.12.0 // indirect github.com/spf13/afero v1.12.0 // indirect
github.com/spf13/cast v1.7.1 // indirect github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect github.com/spf13/pflag v1.0.6 // indirect
github.com/spf13/viper v1.20.1 // indirect
github.com/src-d/gcfg v1.4.0 // indirect github.com/src-d/gcfg v1.4.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect

5
api/job.go Normal file
View File

@@ -0,0 +1,5 @@
package main
func CreateJob(script string) {
}

View File

@@ -0,0 +1,10 @@
begin;
drop table job_step;
drop table jobs;
drop type event;
drop type status;
drop type bash_type;
commit;

View File

@@ -0,0 +1,37 @@
begin;
create type event as enum('push', 'pull_request', 'tags');
create type status as enum('finished', 'waiting', 'running', 'error');
create table jobs(
id int not null primary key,
handle uuid not null,
name varchar(255) not null,
repository_id int not null references repositories(id) on delete cascade,
ref varchar not null,
event event not null,
started_at timestamptz not null,
finished_at timestamptz,
status status not null,
parent int references jobs(id) on delete cascade
);
create type bash_type as enum('command', 'loop', 'if');
create table job_step(
id int not null primary key,
job_id int not null references jobs(id) on delete cascade,
command text not null,
type bash_type not null,
status status not null,
exit_code int,
logs text not null,
started_at timestamptz,
finished_at timestamptz
);
commit;

View File

@@ -3,5 +3,8 @@ pkgs.mkShell {
packages = with pkgs; [ packages = with pkgs; [
go go
websocat websocat
(go-migrate.overrideAttrs (oldAttrs: {
tags = ["postgres"];
}))
]; ];
} }