diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-11-29 09:35:27 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-11-29 09:35:27 +0100 |
commit | 3afcaef927391db23fe23c6c8c26b8960e8dae32 (patch) | |
tree | 143b9f6df9e8c795c8c6ed901bffdc7119f40df1 /bin | |
parent | c4ce3e884a6aa527bcc138771617215cf03265a4 (diff) |
intermediate commit
Diffstat (limited to 'bin')
-rw-r--r-- | bin/db.php (renamed from bin/villages.php) | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/bin/villages.php b/bin/db.php index 092a754..951c0b3 100644 --- a/bin/villages.php +++ b/bin/db.php @@ -25,8 +25,8 @@ DB::query(<<<SQL "food" bigint not null, "satisfaction" bigint not null, - "created_at" timestamp(0) not null, - "updated_at" timestamp(0) not null, + "created_at" timestamp(0) not null default current_timestamp, + "updated_at" timestamp(0) not null default current_timestamp, unique ("x", "y") ); @@ -43,8 +43,8 @@ DB::query(<<<SQL constraint "relation_village" foreign key ("village_id") references villages("id") on delete cascade, - "created_at" timestamp(0) not null, - "updated_at" timestamp(0) not null, + "created_at" timestamp(0) not null default current_timestamp, + "updated_at" timestamp(0) not null default current_timestamp, unique ("type", "village_id") ); @@ -67,8 +67,8 @@ DB::query(<<<SQL constraint "relation_village_residence" foreign key ("residence_village_id") references villages("id") on delete cascade, - "created_at" timestamp(0) not null, - "updated_at" timestamp(0) not null, + "created_at" timestamp(0) not null default current_timestamp, + "updated_at" timestamp(0) not null default current_timestamp, unique ("type", "home_village_id", "residence_village_id") ); @@ -87,8 +87,8 @@ DB::query(<<<SQL constraint "relation_village" foreign key ("village_id") references villages("id") on delete cascade, - "created_at" timestamp(0) not null, - "updated_at" timestamp(0) not null + "created_at" timestamp(0) not null default current_timestamp, + "updated_at" timestamp(0) not null default current_timestamp ); SQL); @@ -96,9 +96,7 @@ DB::query(<<<SQL create table if not exists "events" ( "id" bigserial primary key, - "type" character varying(255) not null, "time" timestamp(0) not null, - "payload" jsonb not null, "village_id" bigint not null, constraint "relation_village" @@ -110,6 +108,21 @@ DB::query(<<<SQL SQL); DB::query(<<<SQL + create table if not exists "events_upgrade_building" ( + "id" bigserial primary key, + + "event_id" bigint not null, + constraint "relation_event" + foreign key ("event_id") references events("id") on delete cascade, + + "type" character varying(255) not null, + + "created_at" timestamp(0) not null default current_timestamp, + "updated_at" timestamp(0) not null default current_timestamp + ); +SQL); + +DB::query(<<<SQL create table if not exists "users" ( "id" bigserial primary key, @@ -117,8 +130,8 @@ DB::query(<<<SQL "password" character varying(255) not null, "email" character varying(255) not null, - "created_at" timestamp(0) not null, - "updated_at" timestamp(0) not null, + "created_at" timestamp(0) not null default current_timestamp, + "updated_at" timestamp(0) not null default current_timestamp, unique ("username") ); @@ -134,8 +147,8 @@ DB::query(<<<SQL constraint "relation_user" foreign key ("user_id") references users("id") on delete cascade, - "created_at" timestamp(0) not null, - "updated_at" timestamp(0) not null + "created_at" timestamp(0) not null default current_timestamp, + "updated_at" timestamp(0) not null default current_timestamp ); SQL); |