added go-migrate Migrations
This commit is contained in:
16
migrations/20250802065143_initial.down.sql
Normal file
16
migrations/20250802065143_initial.down.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- reverse: create "wochen_report" table
|
||||
DROP TABLE "wochen_report";
|
||||
-- reverse: create "user_password" table
|
||||
DROP TABLE "user_password";
|
||||
-- reverse: set comment to column: "geschlecht" on table: "personal_daten"
|
||||
COMMENT ON COLUMN "personal_daten"."geschlecht" IS NULL;
|
||||
-- reverse: create "personal_daten" table
|
||||
DROP TABLE "personal_daten";
|
||||
-- reverse: set comment to column: "geraet_id" on table: "anwesenheit"
|
||||
COMMENT ON COLUMN "anwesenheit"."geraet_id" IS NULL;
|
||||
-- reverse: set comment to column: "check_in_out" on table: "anwesenheit"
|
||||
COMMENT ON COLUMN "anwesenheit"."check_in_out" IS NULL;
|
||||
-- reverse: create "anwesenheit" table
|
||||
DROP TABLE "anwesenheit";
|
||||
-- reverse: create "abwesenheit" table
|
||||
DROP TABLE "abwesenheit";
|
||||
57
migrations/20250802065143_initial.up.sql
Normal file
57
migrations/20250802065143_initial.up.sql
Normal file
@@ -0,0 +1,57 @@
|
||||
-- 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,
|
||||
"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")
|
||||
);
|
||||
10
migrations/20250802075213_control_tables.down.sql
Normal file
10
migrations/20250802075213_control_tables.down.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
-- reverse rename "s_personal_daten" table
|
||||
ALTER TABLE "s_personal_daten" RENAME TO "personal_daten";
|
||||
|
||||
DROP TABLE "s_personal_daten";
|
||||
-- reverse: create "s_anwesenheit_typen" table
|
||||
DROP TABLE "s_anwesenheit_typen";
|
||||
-- reverse: create "s_abwesenheit_typen" table
|
||||
DROP TABLE "s_abwesenheit_typen";
|
||||
-- reverse: modify "anwesenheit" table
|
||||
ALTER TABLE "anwesenheit" DROP COLUMN "manuelle_buchung";
|
||||
16
migrations/20250802075213_control_tables.up.sql
Normal file
16
migrations/20250802075213_control_tables.up.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- modify "anwesenheit" table
|
||||
ALTER TABLE "anwesenheit" ADD COLUMN "manuelle_buchung" boolean NULL;
|
||||
-- create "s_abwesenheit_typen" table
|
||||
CREATE TABLE "s_abwesenheit_typen" (
|
||||
"abwesenheit_id" smallint NOT NULL,
|
||||
"abwesenheit_name" character varying(255) NULL,
|
||||
PRIMARY KEY ("abwesenheit_id")
|
||||
);
|
||||
-- create "s_anwesenheit_typen" table
|
||||
CREATE TABLE "s_anwesenheit_typen" (
|
||||
"anwesenheit_id" smallint NOT NULL,
|
||||
"anwesenheit_name" character varying(255) NULL,
|
||||
PRIMARY KEY ("anwesenheit_id")
|
||||
);
|
||||
-- create "s_personal_daten" table
|
||||
ALTER TABLE "personal_daten" RENAME TO "s_personal_daten";
|
||||
3
migrations/atlas.sum
Normal file
3
migrations/atlas.sum
Normal file
@@ -0,0 +1,3 @@
|
||||
h1:5gPDmrcQS12KjKLuwN1ycTBHtbHbkzd7rUIj01uJrhA=
|
||||
20250802065143_initial.up.sql h1:9cUWduWgONRfI5LV+b3nFvei6DKDqPxcNryKVg1xo80=
|
||||
20250802075213_control_tables.up.sql h1:5vQLBHMM2Sa1FErP5gQUUHAoSiV2RQ0cOlMEEDFcoKA=
|
||||
Reference in New Issue
Block a user