aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md14
-rw-r--r--migrations/00000000000000_diesel_initial_setup/down.sql15
-rw-r--r--migrations/00000000000000_diesel_initial_setup/up.sql2
-rw-r--r--src/schema.rs112
4 files changed, 83 insertions, 60 deletions
diff --git a/README.md b/README.md
index 92d7481..c7519b3 100644
--- a/README.md
+++ b/README.md
@@ -5,18 +5,16 @@ August Offensive is a game as a web service that enables players to achieve worl
The main goal of August Offensive is to enable players to interact with the service only when they are available to do so. Effectively, players do not need to maintain connection to the service for the entirety of the game. To prevent games from deadlocking, a customary time limit is enforced (ex. 96 hours).
-## Getting Started
-
-Getting the code running should be fairly simple. Given you have the properly installed packages (PHP 7.0, PostGreSQL 9.6) there should be few if any configuration changes to existing services. Make sure [your credentials are configured](https://github.com/kjhoerr/august-offensive/wiki/Credentials-for-PGSQL) and try visiting /api/callback at your server - you should get a response if it's set up correctly.
+## Technical Objectives
-In order to run tests, install [PHPUnit](https://phpunit.de/) (for PHP 7.0). At the project root, run `phpunit --bootstrap autoload.php test`.
+The project is built using the [Rust programming language](https://www.rust-lang.org/en-US/), [actix-web](https://actix.rs/) as the web framework, and [Diesel](https://diesel.rs/) for interacting with a PostgreSQL database. Diesel and actix-web work on stable Rust, removing the constant need to support nightly features. In addition, Diesel provides a client that makes it easy to migrate between schemas as they evolve between releases. This helps the project maintain a great level of portability without putting too great pressure on the application code.
-## Technical Objectives
+The front-end of this project will be written using [Elm](https://elm-lang.org/) (although this is subject to change). Development on the front-end portion will not begin until August Offensive's web API has reached relative stability. The target version number for stability is 1.0.0.
-The web service will provide a RESTful API that is written in PHP 7.0 and connects to a PostGreSQL database. This connection will be managed behind an abstraction layer using PDO. The service will handle users and their game sessions. In addition, all PHP code shall follow PSR-1, PSR-2, PSR-4, and PSR-5 coding standards. It is also recommended to try to write code as immutably as possible.
+## Deployment
-The front-end of this project will be written using [Elm](http://elm-lang.org/) (although this is subject to change). Work on the front-end portion will not begin until August Offensive's web API has reached relative stability. The target version number for stability is 1.0.0.
+Visit the Wiki for guides detailing [how to deploy August Offensive](https://github.com/kjhoerr/august-offensive/wiki/Deployment) (e.g. standalone or using Docker).
## Contributing to the Project
-While the project is still getting off the ground, there is not much back-end of which to build off. That doesn't mean you can't help brainstorm at least! There is much about the core functionality that is still up in the air at this point. Please have a look at [the Roadmap](https://github.com/kjhoerr/august-offensive/wiki/Roadmap) for a detailed layout of intended features and / or milestones.
+While the project is still getting off the ground, there is not much back-end of which to build off. That doesn't mean you can't help brainstorm at least! There is much about the core functionality that is still up in the air at this point. Please have a look at [the Roadmap](https://github.com/kjhoerr/august-offensive/wiki/Roadmap) for a detailed layout of intended features and / or milestones. \ No newline at end of file
diff --git a/migrations/00000000000000_diesel_initial_setup/down.sql b/migrations/00000000000000_diesel_initial_setup/down.sql
index 74a7b3d..25f4412 100644
--- a/migrations/00000000000000_diesel_initial_setup/down.sql
+++ b/migrations/00000000000000_diesel_initial_setup/down.sql
@@ -1,11 +1,10 @@
-- down.sql: Destroy initial database migration for AO
-DROP FUNCTION IF EXISTS public.GETDATE();
-DROP TABLE users;
-DROP TABLE activation_keys;
-DROP TABLE games;
-DROP TABLE allegiances;
-DROP TABLE regions;
-DROP TABLE nationstates;
+DROP TABLE games_nationstates;
DROP TABLE borders;
-DROP TABLE games_nationstates; \ No newline at end of file
+DROP TABLE nationstates;
+DROP TABLE regions;
+DROP TABLE allegiances;
+DROP TABLE games;
+DROP TABLE activation_keys;
+DROP TABLE users; \ No newline at end of file
diff --git a/migrations/00000000000000_diesel_initial_setup/up.sql b/migrations/00000000000000_diesel_initial_setup/up.sql
index 83a7869..2140a57 100644
--- a/migrations/00000000000000_diesel_initial_setup/up.sql
+++ b/migrations/00000000000000_diesel_initial_setup/up.sql
@@ -28,7 +28,7 @@ CREATE TABLE activation_keys (
CREATE TABLE games (
gameid SERIAL,
title VARCHAR(140) NOT NULL,
- gametypeid SERIAL NOT NULL, -- future proofing: suppose different game types
+ gametypeid SERIAL NOT NULL, -- future proofing: suppose different game types
players SMALLINT NOT NULL, -- number of players in a game
waitfor INTEGER NOT NULL, -- time in seconds to wait for player to complete a turn
lastturn DATE DEFAULT GETDATE(),
diff --git a/src/schema.rs b/src/schema.rs
index 2f0daba..e5d814b 100644
--- a/src/schema.rs
+++ b/src/schema.rs
@@ -1,66 +1,92 @@
table! {
- users(userid) {
- userid -> Serial,
- email -> VarChar,
- firstname -> VarChar,
- lastname -> VarChar,
- password -> VarChar,
- joindate -> Date,
- activated -> Bool,
+ activation_keys (code) {
+ code -> Varchar,
+ userid -> Int4,
}
}
+
table! {
- activation_keys(code) {
- code -> VarChar,
- userid -> Serial,
+ allegiances (gameid, userid) {
+ gameid -> Int4,
+ userid -> Int4,
+ allegiance -> Nullable<Varchar>,
+ ordernum -> Int2,
+ playing -> Nullable<Int2>,
}
}
+
table! {
- games(gameid) {
- gameid -> Serial,
- title -> VarChar,
- gametypeid -> Serial,
- players -> SmallInt,
- waitfor -> Integer,
- lastturn -> Date,
- gamestate -> Integer,
+ borders (nationid, borderid) {
+ nationid -> Int4,
+ borderid -> Int4,
}
}
+
table! {
- allegiances(gameid, userid) {
- gameid -> Serial,
- userid -> Serial,
- allegiance -> VarChar,
- ordernum -> SmallInt,
- playing -> SmallInt,
+ games (gameid) {
+ gameid -> Int4,
+ title -> Varchar,
+ gametypeid -> Int4,
+ players -> Int2,
+ waitfor -> Int4,
+ lastturn -> Nullable<Date>,
+ gamestate -> Nullable<Int4>,
}
}
+
table! {
- regions(regionid) {
- regionid -> Serial,
- name -> VarChar,
- abbreviation -> Char,
- bonus -> Integer,
+ games_nationstates (gameid, nationid) {
+ gameid -> Int4,
+ nationid -> Int4,
+ userid -> Int4,
}
}
+
table! {
- nationstates(nationid) {
- nationid -> Serial,
- regionid -> Serial,
- name -> VarChar,
- abbreviation -> Char,
+ nationstates (nationid) {
+ nationid -> Int4,
+ regionid -> Int4,
+ name -> Varchar,
+ abbreviation -> Nullable<Bpchar>,
}
}
+
table! {
- borders(nationid, borderid) {
- nationid -> Serial,
- borderid -> Serial,
+ regions (regionid) {
+ regionid -> Int4,
+ name -> Varchar,
+ abbreviation -> Nullable<Bpchar>,
+ bonus -> Int4,
}
}
+
table! {
- regions_nationstates(gameid, nationid) {
- gameid -> Serial,
- nationid -> Serial,
- userid -> Serial,
+ users (userid) {
+ userid -> Int4,
+ email -> Varchar,
+ firstname -> Varchar,
+ lastname -> Varchar,
+ password -> Varchar,
+ joindate -> Nullable<Date>,
+ activated -> Nullable<Bit>,
}
-} \ No newline at end of file
+}
+
+joinable!(activation_keys -> users (userid));
+joinable!(allegiances -> games (gameid));
+joinable!(allegiances -> users (userid));
+joinable!(games_nationstates -> games (gameid));
+joinable!(games_nationstates -> nationstates (nationid));
+joinable!(games_nationstates -> users (userid));
+joinable!(nationstates -> regions (regionid));
+
+allow_tables_to_appear_in_same_query!(
+ activation_keys,
+ allegiances,
+ borders,
+ games,
+ games_nationstates,
+ nationstates,
+ regions,
+ users,
+);