diff options
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); |