forked from lix-project/hydra
* Cleaned up the foreign key constraints.
* Generate SQLite and PostgreSQL schemas from hydra.sql.
This commit is contained in:
parent
2cf42489e2
commit
686b6271d2
|
@ -1,9 +1,6 @@
|
|||
* Recreating the schema bindings:
|
||||
|
||||
$ rm tmp.sqlite
|
||||
$ sqlite3 tmp.sqlite < sql/hydra.sql
|
||||
# $ ~/bin/genfkey tmp.sqlite > sql/fk-triggers.sql
|
||||
$ perl -MDBIx::Class::Schema::Loader=make_schema_at,dump_to_dir:./lib -e 'make_schema_at("Hydra::Schema", { relationships => 1, moniker_map => sub {return $_;} }, ["dbi:SQLite:tmp.sqlite"])'
|
||||
$ make -C src/sql update-dbix
|
||||
|
||||
* Running the test server:
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ let
|
|||
cp $jquery src/root/static/js/jquery-pack.js
|
||||
rm -rf src/root/static/js/tablesorter
|
||||
unzip -d src/root/static/js $tablesorter
|
||||
|
||||
make -C src/sql
|
||||
|
||||
releaseName=hydra-0.1$VERSION_SUFFIX;
|
||||
ensureDir $out/tarballs
|
||||
|
|
|
@ -8,8 +8,8 @@ use base 'DBIx::Class::Schema';
|
|||
__PACKAGE__->load_classes;
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ODLRc6VfDQpb8MyXPKmqtg
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Fs+amiko3zHOhK97IatSgQ
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -103,8 +103,8 @@ __PACKAGE__->belongs_to(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:gtA3wQA2CLsXs4X95PfX9A
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7blxTiVkvfdukDiXCoD+Lw
|
||||
|
||||
use Hydra::Helper::Nix;
|
||||
|
||||
|
|
|
@ -91,8 +91,8 @@ __PACKAGE__->set_primary_key("build", "productnr");
|
|||
__PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" });
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ii6N3v4M1fX1tQ3YmJNFWw
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8wtm75jCRmcyWInKMO826g
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -86,8 +86,8 @@ __PACKAGE__->set_primary_key("id");
|
|||
__PACKAGE__->belongs_to("id", "Hydra::Schema::Builds", { id => "id" });
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EMvF2g+MDIE84yjnJOs7og
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3P0UuNHhdA8VfALMfwssTA
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
"failedDep",
|
||||
|
|
|
@ -43,8 +43,8 @@ __PACKAGE__->set_primary_key("id");
|
|||
__PACKAGE__->belongs_to("id", "Hydra::Schema::Builds", { id => "id" });
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RcdX5dHefBQnxQYbMxNF/w
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:e4O2JqrJN8coHmRdjbbxHg
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -91,7 +91,7 @@ __PACKAGE__->set_primary_key("build", "stepnr");
|
|||
__PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" });
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1AQCHpuv8Lqk/FYdU8JYFA
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/Qdb8Y3Tqw7AOM5ique5Nw
|
||||
|
||||
1;
|
||||
|
|
|
@ -163,8 +163,8 @@ __PACKAGE__->has_many(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CcYlMej7OPRUJn6375Qlqw
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:eJS7WCbSjwylQuAbQtB24w
|
||||
|
||||
use Hydra::Helper::Nix;
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ __PACKAGE__->add_columns(
|
|||
__PACKAGE__->set_primary_key("srcpath", "sha256hash");
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mYBdemei1tFuK8Ll6eMLfQ
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FcLeNgdEr13JAYZLxF4/tw
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -40,8 +40,8 @@ __PACKAGE__->add_columns(
|
|||
__PACKAGE__->set_primary_key("uri", "revision");
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bE+w54cACUS2L0PJ9gPjtw
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:y14yX+UAP03N7VGrgehcLw
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -58,6 +58,12 @@ __PACKAGE__->add_columns(
|
|||
{ data_type => "integer", default_value => 0, is_nullable => 0, size => undef },
|
||||
);
|
||||
__PACKAGE__->set_primary_key("project", "jobset", "name");
|
||||
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" });
|
||||
__PACKAGE__->belongs_to(
|
||||
"jobset",
|
||||
"Hydra::Schema::Jobsets",
|
||||
{ name => "jobset", project => "project" },
|
||||
);
|
||||
__PACKAGE__->has_many(
|
||||
"builds",
|
||||
"Hydra::Schema::Builds",
|
||||
|
@ -67,16 +73,10 @@ __PACKAGE__->has_many(
|
|||
"foreign.project" => "self.project",
|
||||
},
|
||||
);
|
||||
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" });
|
||||
__PACKAGE__->belongs_to(
|
||||
"jobset",
|
||||
"Hydra::Schema::Jobsets",
|
||||
{ name => "jobset", project => "project" },
|
||||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:c0OEe2zPd/E4vh0PRXm4Ag
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AjrYM1rAdgYy3j0+IFFUEw
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -69,8 +69,8 @@ __PACKAGE__->belongs_to(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jS8pitmHFnplE8WcK0OyMQ
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:o5NC1PPpGrzOZZcumFoudg
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -65,8 +65,8 @@ __PACKAGE__->has_many(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:W0rhMTOzLBZNsVShQHg5+A
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7A5UkNWAqy0XuhlKvOgr6Q
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -71,14 +71,6 @@ __PACKAGE__->add_columns(
|
|||
{ data_type => "integer", default_value => 1, is_nullable => 0, size => undef },
|
||||
);
|
||||
__PACKAGE__->set_primary_key("project", "name");
|
||||
__PACKAGE__->has_many(
|
||||
"builds",
|
||||
"Hydra::Schema::Builds",
|
||||
{
|
||||
"foreign.jobset" => "self.name",
|
||||
"foreign.project" => "self.project",
|
||||
},
|
||||
);
|
||||
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" });
|
||||
__PACKAGE__->belongs_to(
|
||||
"jobsetinput",
|
||||
|
@ -101,10 +93,18 @@ __PACKAGE__->has_many(
|
|||
"foreign.project" => "self.project",
|
||||
},
|
||||
);
|
||||
__PACKAGE__->has_many(
|
||||
"builds",
|
||||
"Hydra::Schema::Builds",
|
||||
{
|
||||
"foreign.jobset" => "self.name",
|
||||
"foreign.project" => "self.project",
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CB5lPsrozpvO8gLXHTyMrQ
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vaCDa6WBFdcLMG23Nlr27g
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -48,11 +48,6 @@ __PACKAGE__->add_columns(
|
|||
},
|
||||
);
|
||||
__PACKAGE__->set_primary_key("name");
|
||||
__PACKAGE__->has_many(
|
||||
"builds",
|
||||
"Hydra::Schema::Builds",
|
||||
{ "foreign.project" => "self.name" },
|
||||
);
|
||||
__PACKAGE__->belongs_to("owner", "Hydra::Schema::Users", { username => "owner" });
|
||||
__PACKAGE__->has_many(
|
||||
"jobsets",
|
||||
|
@ -64,6 +59,11 @@ __PACKAGE__->has_many(
|
|||
"Hydra::Schema::Jobs",
|
||||
{ "foreign.project" => "self.name" },
|
||||
);
|
||||
__PACKAGE__->has_many(
|
||||
"builds",
|
||||
"Hydra::Schema::Builds",
|
||||
{ "foreign.project" => "self.name" },
|
||||
);
|
||||
__PACKAGE__->has_many(
|
||||
"views",
|
||||
"Hydra::Schema::Views",
|
||||
|
@ -76,8 +76,8 @@ __PACKAGE__->has_many(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:N6NPLJfc1gKM4zz6dS5PJw
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:XcrLhOH+WuO24UFulGft1w
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -21,8 +21,8 @@ __PACKAGE__->add_columns(
|
|||
__PACKAGE__->set_primary_key("system");
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EkpopxgwlZf8Du3EmWzTKQ
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:X1voxjTNUQrn04o0zyVZ+w
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -28,8 +28,8 @@ __PACKAGE__->set_primary_key("username", "role");
|
|||
__PACKAGE__->belongs_to("username", "Hydra::Schema::Users", { username => "username" });
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:W2Q6219GlZl2IqQkBoFmFA
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hbm45HCbdLU4emCiCC5gyA
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -38,20 +38,20 @@ __PACKAGE__->add_columns(
|
|||
},
|
||||
);
|
||||
__PACKAGE__->set_primary_key("username");
|
||||
__PACKAGE__->has_many(
|
||||
"projects",
|
||||
"Hydra::Schema::Projects",
|
||||
{ "foreign.owner" => "self.username" },
|
||||
);
|
||||
__PACKAGE__->has_many(
|
||||
"userroles",
|
||||
"Hydra::Schema::UserRoles",
|
||||
{ "foreign.username" => "self.username" },
|
||||
);
|
||||
__PACKAGE__->has_many(
|
||||
"projects",
|
||||
"Hydra::Schema::Projects",
|
||||
{ "foreign.owner" => "self.username" },
|
||||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qH+qBI3xxQgTNf3v7E3sDw
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4Lj9iNcQhOG5VzUXkQFzkg
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -66,8 +66,8 @@ __PACKAGE__->belongs_to(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LkiGAkZOiLNJk6oDY0+zNw
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:63nUKTtC6XdTSawDvU+oFg
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -42,8 +42,8 @@ __PACKAGE__->has_many(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hV+xzi564rgcYeDvz75zCA
|
||||
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 14:17:55
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+x+gzFpHSZzVMlsjMn47UA
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
12
src/sql/Makefile
Normal file
12
src/sql/Makefile
Normal file
|
@ -0,0 +1,12 @@
|
|||
all: hydra-postgresql.sql hydra-sqlite.sql
|
||||
|
||||
hydra-postgresql.sql: hydra.sql
|
||||
cpp -P -E -traditional-cpp -DPOSTGRESQL hydra.sql > $@ || rm -f $@
|
||||
|
||||
hydra-sqlite.sql: hydra.sql
|
||||
cpp -P -E -traditional-cpp -DSQLITE hydra.sql > $@ || rm -f $@
|
||||
|
||||
update-dbix: hydra-sqlite.sql
|
||||
rm -f tmp.sqlite
|
||||
sqlite3 tmp.sqlite < hydra-sqlite.sql
|
||||
perl -MDBIx::Class::Schema::Loader=make_schema_at,dump_to_dir:../lib -e 'make_schema_at("Hydra::Schema", { relationships => 1, moniker_map => sub {return $$_;} }, ["dbi:SQLite:tmp.sqlite"])'
|
|
@ -1,10 +1,116 @@
|
|||
create table Users (
|
||||
userName text primary key not null,
|
||||
fullName text,
|
||||
emailAddress text not null,
|
||||
password text not null -- sha256 hash
|
||||
);
|
||||
|
||||
|
||||
create table UserRoles (
|
||||
userName text not null,
|
||||
role text not null,
|
||||
primary key (userName, role),
|
||||
foreign key (userName) references Users(userName) on delete cascade on update cascade
|
||||
);
|
||||
|
||||
|
||||
create table Projects (
|
||||
name text primary key not null, -- project id, lowercase (e.g. "patchelf")
|
||||
displayName text not null, -- display name (e.g. "PatchELF")
|
||||
description text,
|
||||
enabled integer not null default 1,
|
||||
owner text not null,
|
||||
homepage text, -- URL for the project
|
||||
foreign key (owner) references Users(userName) on update cascade
|
||||
);
|
||||
|
||||
|
||||
-- A jobset consists of a set of inputs (e.g. SVN repositories), one
|
||||
-- of which contains a Nix expression containing an attribute set
|
||||
-- describing build jobs.
|
||||
create table Jobsets (
|
||||
name text not null,
|
||||
project text not null,
|
||||
description text,
|
||||
nixExprInput text not null, -- name of the jobsetInput containing the Nix expression
|
||||
nixExprPath text not null, -- relative path of the Nix expression
|
||||
errorMsg text, -- used to signal the last evaluation error etc. for this jobset
|
||||
errorTime integer, -- timestamp associated with errorMsg
|
||||
lastCheckedTime integer, -- last time the scheduler looked at this jobset
|
||||
enabled integer not null default 1,
|
||||
primary key (project, name),
|
||||
foreign key (project) references Projects(name) on delete cascade on update cascade
|
||||
#ifdef SQLITE
|
||||
,
|
||||
foreign key (project, name, nixExprInput) references JobsetInputs(project, jobset, name)
|
||||
#endif
|
||||
);
|
||||
|
||||
|
||||
create table JobsetInputs (
|
||||
project text not null,
|
||||
jobset text not null,
|
||||
name text not null,
|
||||
type text not null, -- "svn", "cvs", "path", "uri", "string", "boolean"
|
||||
primary key (project, jobset, name),
|
||||
foreign key (project, jobset) references Jobsets(project, name) on delete cascade on update cascade
|
||||
);
|
||||
|
||||
|
||||
#ifdef POSTGRESQL
|
||||
alter table Jobsets
|
||||
add foreign key (project, name, nixExprInput)
|
||||
references JobsetInputs(project, jobset, name);
|
||||
#endif
|
||||
|
||||
|
||||
create table JobsetInputAlts (
|
||||
project text not null,
|
||||
jobset text not null,
|
||||
input text not null,
|
||||
altnr integer not null,
|
||||
|
||||
-- urgh
|
||||
value text, -- for most types, a URI; for 'path', an absolute path; for 'string', an arbitrary value
|
||||
revision integer, -- for type == 'svn'
|
||||
tag text, -- for type == 'cvs'
|
||||
|
||||
primary key (project, jobset, input, altnr),
|
||||
foreign key (project, jobset, input) references JobsetInputs(project, jobset, name) on delete cascade on update cascade
|
||||
);
|
||||
|
||||
|
||||
create table Jobs (
|
||||
project text not null,
|
||||
jobset text not null,
|
||||
name text not null,
|
||||
|
||||
active integer not null default 1, -- !!! obsolete, remove
|
||||
|
||||
errorMsg text, -- evalution error for this job
|
||||
|
||||
firstEvalTime integer, -- first time the scheduler saw this job
|
||||
lastEvalTime integer, -- last time the scheduler saw this job
|
||||
|
||||
disabled integer not null default 0, -- !!! not currently used
|
||||
|
||||
primary key (project, jobset, name),
|
||||
foreign key (project) references Projects(name) on delete cascade on update cascade,
|
||||
foreign key (project, jobset) references Jobsets(project, name) on delete cascade on update cascade
|
||||
);
|
||||
|
||||
|
||||
-- This table contains all builds, either scheduled or finished. For
|
||||
-- scheduled builds, additional info (such as the priority) can be
|
||||
-- found in the BuildSchedulingInfo table. For finished builds,
|
||||
-- additional info (such as the logs, build products, etc.) can be
|
||||
-- found in several tables, such as BuildResultInfo and BuildProducts.
|
||||
create table Builds (
|
||||
#ifdef POSTGRESQL
|
||||
id serial primary key not null,
|
||||
#else
|
||||
id integer primary key autoincrement not null,
|
||||
#endif
|
||||
|
||||
finished integer not null, -- 0 = scheduled, 1 = finished
|
||||
|
||||
|
@ -29,9 +135,9 @@ create table Builds (
|
|||
|
||||
isCurrent integer default 0,
|
||||
|
||||
foreign key (project) references Projects(name), -- ignored by sqlite
|
||||
foreign key (project, jobset) references Jobsets(project, name), -- ignored by sqlite
|
||||
foreign key (project, jobset, job) references Jobs(project, jobset, name) -- ignored by sqlite
|
||||
foreign key (project) references Projects(name) on update cascade,
|
||||
foreign key (project, jobset) references Jobsets(project, name) on update cascade,
|
||||
foreign key (project, jobset, job) references Jobs(project, jobset, name) on update cascade
|
||||
);
|
||||
|
||||
|
||||
|
@ -50,7 +156,7 @@ create table BuildSchedulingInfo (
|
|||
|
||||
startTime integer, -- if busy, time we started
|
||||
|
||||
foreign key (id) references Builds(id) on delete cascade -- ignored by sqlite
|
||||
foreign key (id) references Builds(id) on delete cascade
|
||||
);
|
||||
|
||||
|
||||
|
@ -83,7 +189,7 @@ create table BuildResultInfo (
|
|||
failedDepBuild integer, -- obsolete
|
||||
failedDepStepNr integer, -- obsolete
|
||||
|
||||
foreign key (id) references Builds(id) on delete cascade -- ignored by sqlite
|
||||
foreign key (id) references Builds(id) on delete cascade
|
||||
);
|
||||
|
||||
|
||||
|
@ -108,13 +214,17 @@ create table BuildSteps (
|
|||
stopTime integer,
|
||||
|
||||
primary key (build, stepnr),
|
||||
foreign key (build) references Builds(id) on delete cascade -- ignored by sqlite
|
||||
foreign key (build) references Builds(id) on delete cascade
|
||||
);
|
||||
|
||||
|
||||
-- Inputs of builds.
|
||||
create table BuildInputs (
|
||||
create table BuildInputs (
|
||||
#ifdef POSTGRESQL
|
||||
id serial primary key not null,
|
||||
#else
|
||||
id integer primary key autoincrement not null,
|
||||
#endif
|
||||
|
||||
-- Which build this input belongs to.
|
||||
build integer,
|
||||
|
@ -132,8 +242,8 @@ create table BuildInputs (
|
|||
|
||||
sha256hash text,
|
||||
|
||||
foreign key (build) references Builds(id) on delete cascade, -- ignored by sqlite
|
||||
foreign key (dependency) references Builds(id) -- ignored by sqlite
|
||||
foreign key (build) references Builds(id) on delete cascade,
|
||||
foreign key (dependency) references Builds(id)
|
||||
);
|
||||
|
||||
|
||||
|
@ -150,130 +260,7 @@ create table BuildProducts (
|
|||
description text, -- optionally, some description of this file/directory
|
||||
defaultPath text, -- if `path' is a directory, the default file relative to `path' to be served
|
||||
primary key (build, productnr),
|
||||
foreign key (build) references Builds(id) on delete cascade -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
-- Emulate "on delete cascade" foreign key constraints.
|
||||
create trigger cascadeBuildDeletion
|
||||
before delete on Builds
|
||||
for each row begin
|
||||
delete from BuildSchedulingInfo where id = old.id;
|
||||
delete from BuildResultInfo where id = old.id;
|
||||
delete from BuildInputs where build = old.id;
|
||||
delete from BuildProducts where build = old.id;
|
||||
delete from BuildSteps where build = old.id;
|
||||
end;
|
||||
|
||||
|
||||
create table Projects (
|
||||
name text primary key not null, -- project id, lowercase (e.g. "patchelf")
|
||||
displayName text not null, -- display name (e.g. "PatchELF")
|
||||
description text,
|
||||
enabled integer not null default 1,
|
||||
owner text not null,
|
||||
homepage text, -- URL for the project
|
||||
foreign key (owner) references Users(userName) -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
create trigger cascadeProjectUpdate
|
||||
update of name on Projects
|
||||
for each row begin
|
||||
update Jobsets set project = new.name where project = old.name;
|
||||
update JobsetInputs set project = new.name where project = old.name;
|
||||
update JobsetInputAlts set project = new.name where project = old.name;
|
||||
update Builds set project = new.name where project = old.name;
|
||||
update Views set project = new.name where project = old.name;
|
||||
update ViewJobs set project = new.name where project = old.name;
|
||||
end;
|
||||
|
||||
|
||||
-- A jobset consists of a set of inputs (e.g. SVN repositories), one
|
||||
-- of which contains a Nix expression containing an attribute set
|
||||
-- describing build jobs.
|
||||
create table Jobsets (
|
||||
name text not null,
|
||||
project text not null,
|
||||
description text,
|
||||
nixExprInput text not null, -- name of the jobsetInput containing the Nix expression
|
||||
nixExprPath text not null, -- relative path of the Nix expression
|
||||
errorMsg text, -- used to signal the last evaluation error etc. for this jobset
|
||||
errorTime integer, -- timestamp associated with errorMsg
|
||||
lastCheckedTime integer, -- last time the scheduler looked at this jobset
|
||||
enabled integer not null default 1,
|
||||
primary key (project, name),
|
||||
foreign key (project) references Projects(name) on delete cascade, -- ignored by sqlite
|
||||
foreign key (project, name, nixExprInput) references JobsetInputs(project, jobset, name)
|
||||
);
|
||||
|
||||
|
||||
create trigger cascadeJobsetUpdate
|
||||
update of name on Jobsets
|
||||
for each row begin
|
||||
update JobsetInputs set jobset = new.name where project = old.project and jobset = old.name;
|
||||
update JobsetInputAlts set jobset = new.name where project = old.project and jobset = old.name;
|
||||
update Builds set jobset = new.name where project = old.project and jobset = old.name;
|
||||
end;
|
||||
|
||||
|
||||
create table JobsetInputs (
|
||||
project text not null,
|
||||
jobset text not null,
|
||||
name text not null,
|
||||
type text not null, -- "svn", "cvs", "path", "uri", "string", "boolean"
|
||||
primary key (project, jobset, name),
|
||||
foreign key (project, jobset) references Jobsets(project, name) on delete cascade -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
create trigger cascadeJobsetInputUpdate
|
||||
update of name on JobsetInputs
|
||||
for each row begin
|
||||
update JobsetInputAlts set input = new.name where project = old.project and jobset = old.jobset and input = old.name;
|
||||
end;
|
||||
|
||||
|
||||
create trigger cascadeJobsetInputDelete
|
||||
before delete on JobsetInputs
|
||||
for each row begin
|
||||
delete from JobsetInputAlts where project = old.project and jobset = old.jobset and input = old.name;
|
||||
end;
|
||||
|
||||
|
||||
create table JobsetInputAlts (
|
||||
project text not null,
|
||||
jobset text not null,
|
||||
input text not null,
|
||||
altnr integer not null,
|
||||
|
||||
-- urgh
|
||||
value text, -- for most types, a URI; for 'path', an absolute path; for 'string', an arbitrary value
|
||||
revision integer, -- for type == 'svn'
|
||||
tag text, -- for type == 'cvs'
|
||||
|
||||
primary key (project, jobset, input, altnr),
|
||||
foreign key (project, jobset, input) references JobsetInputs(project, jobset, name) on delete cascade -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
create table Jobs (
|
||||
project text not null,
|
||||
jobset text not null,
|
||||
name text not null,
|
||||
|
||||
active integer not null default 1, -- !!! obsolete, remove
|
||||
|
||||
errorMsg text, -- evalution error for this job
|
||||
|
||||
firstEvalTime integer, -- first time the scheduler saw this job
|
||||
lastEvalTime integer, -- last time the scheduler saw this job
|
||||
|
||||
disabled integer not null default 0, -- !!! not currently used
|
||||
|
||||
primary key (project, jobset, name),
|
||||
foreign key (project) references Projects(name) on delete cascade, -- ignored by sqlite
|
||||
foreign key (project, jobset) references Jobsets(project, name) on delete cascade -- ignored by sqlite
|
||||
foreign key (build) references Builds(id) on delete cascade
|
||||
);
|
||||
|
||||
|
||||
|
@ -306,29 +293,6 @@ create table SystemTypes (
|
|||
);
|
||||
|
||||
|
||||
create table Users (
|
||||
userName text primary key not null,
|
||||
fullName text,
|
||||
emailAddress text not null,
|
||||
password text not null -- sha256 hash
|
||||
);
|
||||
|
||||
|
||||
create table UserRoles (
|
||||
userName text not null,
|
||||
role text not null,
|
||||
primary key (userName, role),
|
||||
foreign key (userName) references Users(userName) -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
create trigger cascadeUserDelete
|
||||
before delete on Users
|
||||
for each row begin
|
||||
delete from UserRoles where userName = old.userName;
|
||||
end;
|
||||
|
||||
|
||||
-- Views are a mechanism to automatically group related builds
|
||||
-- together. A view definition consists of a build of some "primary"
|
||||
-- job, plus all builds of the other jobs named in ViewJobs that have
|
||||
|
@ -345,24 +309,10 @@ create table Views (
|
|||
keep integer not null default 0,
|
||||
|
||||
primary key (project, name),
|
||||
foreign key (project) references Projects(name) on delete cascade -- ignored by sqlite
|
||||
foreign key (project) references Projects(name) on delete cascade on update cascade
|
||||
);
|
||||
|
||||
|
||||
create trigger cascadeViewDelete
|
||||
before delete on Views
|
||||
for each row begin
|
||||
delete from ViewJobs where project = old.project and view_ = old.name;
|
||||
end;
|
||||
|
||||
|
||||
create trigger cascadeViewUpdate
|
||||
update of name on Views
|
||||
for each row begin
|
||||
update ViewJobs set view_ = new.name where project = old.project and view_ = old.name;
|
||||
end;
|
||||
|
||||
|
||||
create table ViewJobs (
|
||||
project text not null,
|
||||
view_ text not null,
|
||||
|
@ -389,9 +339,8 @@ create table ViewJobs (
|
|||
autoRelease integer not null default 0,
|
||||
|
||||
primary key (project, view_, job, attrs),
|
||||
foreign key (project) references Projects(name) on delete cascade, -- ignored by sqlite
|
||||
foreign key (project, view_) references Views(project, name) on delete cascade -- ignored by sqlite
|
||||
foreign key (project, jobset) references Jobsets(project, name) on delete restrict -- ignored by sqlite
|
||||
foreign key (project) references Projects(name) on delete cascade on update cascade,
|
||||
foreign key (project, view_) references Views(project, name) on delete cascade on update cascade
|
||||
);
|
||||
|
||||
|
||||
|
@ -404,3 +353,79 @@ create index IndexBuildsByIsCurrent on Builds(isCurrent);
|
|||
create index IndexBuildResultInfo on BuildResultInfo(id); -- primary key index, not created automatically by PostgreSQL
|
||||
create index IndexBuild on BuildProducts(build);
|
||||
create index IndexBuildType on BuildProducts(build, type);
|
||||
|
||||
|
||||
#ifdef SQLITE
|
||||
|
||||
-- Emulate some "on delete/update cascade" foreign key constraints,
|
||||
-- which SQLite doesn't support yet.
|
||||
|
||||
|
||||
create trigger cascadeBuildDeletion
|
||||
before delete on Builds
|
||||
for each row begin
|
||||
delete from BuildSchedulingInfo where id = old.id;
|
||||
delete from BuildResultInfo where id = old.id;
|
||||
delete from BuildInputs where build = old.id;
|
||||
delete from BuildProducts where build = old.id;
|
||||
delete from BuildSteps where build = old.id;
|
||||
end;
|
||||
|
||||
|
||||
create trigger cascadeProjectUpdate
|
||||
update of name on Projects
|
||||
for each row begin
|
||||
update Jobsets set project = new.name where project = old.name;
|
||||
update JobsetInputs set project = new.name where project = old.name;
|
||||
update JobsetInputAlts set project = new.name where project = old.name;
|
||||
update Builds set project = new.name where project = old.name;
|
||||
update Views set project = new.name where project = old.name;
|
||||
update ViewJobs set project = new.name where project = old.name;
|
||||
end;
|
||||
|
||||
|
||||
create trigger cascadeJobsetUpdate
|
||||
update of name on Jobsets
|
||||
for each row begin
|
||||
update JobsetInputs set jobset = new.name where project = old.project and jobset = old.name;
|
||||
update JobsetInputAlts set jobset = new.name where project = old.project and jobset = old.name;
|
||||
update Builds set jobset = new.name where project = old.project and jobset = old.name;
|
||||
end;
|
||||
|
||||
|
||||
create trigger cascadeJobsetInputUpdate
|
||||
update of name on JobsetInputs
|
||||
for each row begin
|
||||
update JobsetInputAlts set input = new.name where project = old.project and jobset = old.jobset and input = old.name;
|
||||
end;
|
||||
|
||||
|
||||
create trigger cascadeJobsetInputDelete
|
||||
before delete on JobsetInputs
|
||||
for each row begin
|
||||
delete from JobsetInputAlts where project = old.project and jobset = old.jobset and input = old.name;
|
||||
end;
|
||||
|
||||
|
||||
create trigger cascadeUserDelete
|
||||
before delete on Users
|
||||
for each row begin
|
||||
delete from UserRoles where userName = old.userName;
|
||||
end;
|
||||
|
||||
|
||||
create trigger cascadeViewDelete
|
||||
before delete on Views
|
||||
for each row begin
|
||||
delete from ViewJobs where project = old.project and view_ = old.name;
|
||||
end;
|
||||
|
||||
|
||||
create trigger cascadeViewUpdate
|
||||
update of name on Views
|
||||
for each row begin
|
||||
update ViewJobs set view_ = new.name where project = old.project and view_ = old.name;
|
||||
end;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
0
src/sql/sqlite.sql
Normal file
0
src/sql/sqlite.sql
Normal file
Loading…
Reference in a new issue