diff --git a/atlas.hcl b/atlas.hcl new file mode 100644 index 0000000..ebc39a6 --- /dev/null +++ b/atlas.hcl @@ -0,0 +1,10 @@ +# The "dev" environment represents our local testings. +env "local" { + url = "postgres://root:very_secure@:5432/arbeitszeitmessung?search_path=public&sslmode=disable" + migration { + dir = "file://migrations" + format = golang-migrate + } + dev = "docker://postgres/16/dev?search_path=public" + src = "file://schema.sql" +} diff --git a/schema.sql b/schema.sql new file mode 100644 index 0000000..55dcecd --- /dev/null +++ b/schema.sql @@ -0,0 +1,58 @@ +-- Create "abwesenheit" table +CREATE TABLE "abwesenheit" ( + "counter_id" bigserial NOT NULL, + "card_uid" character varying(255) NULL, + "abwesenheit_typ" smallint NULL, + "datum" timestamptz NULL DEFAULT (now())::date, + PRIMARY KEY ("counter_id") +); +-- Create "anwesenheit" table +CREATE TABLE "anwesenheit" ( + "counter_id" bigserial NOT NULL, + "timestamp" timestamptz NULL DEFAULT CURRENT_TIMESTAMP, + "card_uid" character varying(255) NULL, + "check_in_out" smallint NULL, + "anwesenheit_type" smallint NULL, + "geraet_id" smallint NULL, + PRIMARY KEY ("counter_id") +); +-- Set comment to column: "check_in_out" on table: "anwesenheit" +COMMENT ON COLUMN "anwesenheit"."check_in_out" IS '1=Check In 2=Check Out , 3=Check in Manuell, 4=Check out manuell255=Automatic Check Out'; +-- Set comment to column: "geraet_id" on table: "anwesenheit" +COMMENT ON COLUMN "anwesenheit"."geraet_id" IS 'ID des Lesegerätes'; +-- Create "personal_daten" table +CREATE TABLE "personal_daten" ( + "personal_nummer" integer NOT NULL, + "aktiv_beschaeftigt" boolean NULL, + "vorname" character varying(255) NULL, + "nachname" character varying(255) NULL, + "geburtsdatum" date NULL, + "plz" character varying(255) NULL, + "adresse" character varying(255) NULL, + "geschlecht" smallint NULL, + "card_uid" character varying(255) NULL, + "hauptbeschaeftigungs_ort" smallint NULL, + "arbeitszeit_per_tag" real NULL, + "arbeitszeit_min_start" time NULL, + "arbeitszeit_max_ende" time NULL, + "vorgesetzter_pers_nr" integer NULL, + PRIMARY KEY ("personal_nummer") +); +-- Set comment to column: "geschlecht" on table: "personal_daten" +COMMENT ON COLUMN "personal_daten"."geschlecht" IS '1==weiblich, 2==maennlich, 3==divers'; +-- Create "user_password" table +CREATE TABLE "user_password" ( + "personal_nummer" integer NOT NULL, + "pass_hash" text NULL, + "zuletzt_geandert" timestamp NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY ("personal_nummer") +); +-- Create "wochen_report" table +CREATE TABLE "wochen_report" ( + "id" serial NOT NULL, + "personal_nummer" integer NULL, + "woche_start" date NULL, + "bestaetigt" boolean NULL DEFAULT false, + PRIMARY KEY ("id"), + CONSTRAINT "wochen_report_personal_nummer_woche_start_key" UNIQUE ("personal_nummer", "woche_start") +);