Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player serialization from-and to SQL database #496

Open
wants to merge 49 commits into
base: kotlin-experiments
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
b9ff3e8
Add database project including initial schema and postgres nvironment
sinoz May 29, 2020
b2eced5
Add connection pooling and use TestContainers for integration tests a…
sinoz May 29, 2020
ec93fdb
Apply feedback and expand
sinoz May 29, 2020
3b575d4
Add title
sinoz May 29, 2020
7988a45
Add games room skill level
sinoz May 29, 2020
e29d7b7
Add attribute table
sinoz May 29, 2020
64607d7
Change p_owner to p_display_name
sinoz May 29, 2020
babf292
Add create_item, create_attribute procedures
sinoz May 29, 2020
02464f6
Turn default appearance values into required procedure parameters for…
sinoz May 29, 2020
da12a6d
Add comment about reserved keyword 'position'
sinoz May 29, 2020
54f2e6f
Use CIText for email
sinoz May 29, 2020
54277e8
Remove character limits
sinoz May 29, 2020
6738931
Update all limitless varchars to text
sinoz May 29, 2020
e85e261
Update ConnectionConfig to simply rely on a URL instead of separate h…
sinoz May 29, 2020
0e368c3
Rename ConnectionPool#hikariPool to ConnectionPool#createHikariPool
sinoz May 29, 2020
4482f54
Update appearance table to borrow the player_id as its primary key
sinoz May 29, 2020
3dd9385
Remove duplicate create_account procedure
sinoz May 29, 2020
17a841c
Add energy units field
sinoz May 29, 2020
0b5a1b5
Remove all drops, add attributes as jsonb to item, add get_skills, ge…
sinoz May 29, 2020
b15f348
Add get_player function, get_appearance
sinoz May 29, 2020
390ac79
Inventory_type -> Inventory_id
sinoz May 29, 2020
b60dcbd
Rename password -> password_hash, remove attributes field from item t…
sinoz May 30, 2020
4ee6b29
Add last_login field, remove extra calls from create_player
sinoz May 30, 2020
46b263f
Remove email field from returned table in get_account
sinoz May 30, 2020
ba11b2c
Turn title into a separate table
sinoz May 30, 2020
15b47dc
Add account related domain types
sinoz May 30, 2020
0a45ae9
Move positional coords right into the player table, apply some clean ups
sinoz May 30, 2020
3341dac
Add player loading, account domain types
sinoz May 30, 2020
8771571
Rename ACCOUNT_FETCH_QUERY -> GET_ACCOUNT_QUERY
sinoz May 30, 2020
cc00840
Add thieving skill
sinoz May 30, 2020
fa4ed80
Add player saving
sinoz May 30, 2020
92bc7f4
Add in support for different types of attributes
sinoz May 30, 2020
e1f48cb
Slightly clean up JdbcPlayerSerializer
sinoz May 30, 2020
6b6c3b6
Remove energy units and games room skill level from player table
sinoz May 30, 2020
45bc21d
Update JdbcPlayerSerializer#putAttributes to not persist transient at…
sinoz May 30, 2020
a5e72c1
Update password in PlayerCredentials to password hash after password …
sinoz May 31, 2020
2ee7eda
Undo the getRunEnergy() return type change
sinoz May 31, 2020
d78334a
Use Guava's MoreObjects for toString()
sinoz Jun 8, 2020
02fa934
Remove value wrappers
sinoz Jun 8, 2020
a0a00fe
Remove entire database package
sinoz Jun 8, 2020
11a43cc
Update JdbcPlayerSerializer to consume a DataSource
sinoz Jun 8, 2020
3d54000
Rename Skill#getCount to Skill#count
sinoz Jun 8, 2020
7e1429e
Remove redundant database module, move schema and associated files to…
sinoz Jun 8, 2020
63b5b09
Update comments
sinoz Jun 8, 2020
0df0d56
Fix test to not rely on Docker and instead accept JDBC url
sinoz Jun 8, 2020
46f9def
Remove testcontainers dependency
sinoz Jun 8, 2020
560876c
Wrap operations in JdbcPlayerSerializer#savePlayer in a transaction
sinoz Jun 8, 2020
f73367b
Update getRunEnergy() to return a long
sinoz Jun 8, 2020
2e5c258
Move sql functions to ApolloQueries.kt
sinoz Jun 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions database/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Tell Docker to pull a Postgres 11 image running on Alpine
FROM postgres:11-alpine

# And then copy over the apollo.sql script into the container's entrypoint
COPY apollo.sql /docker-entrypoint-initdb.d/init.sql
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to start publishing custom PostgreSQL Docker images unless we need to compile native extensions. Instead of using the containers init scripts functionality we should be using something like Flyway to run migrations on the configured database.

38 changes: 38 additions & 0 deletions database/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Apollo - Database
sinoz marked this conversation as resolved.
Show resolved Hide resolved

Contains the database schema for the Apollo project. Start-up and tear-down scripts are included as well as Docker related files. These scripts rely on Docker so it is required to have Docker installed on your machine. This means that you may require an operating system that supports Hyper-V, which include (but are not limited to):
- Windows 10 Professional+
- Linux distributions
- MacOS distributions

Windows 10 Home is not supported as is specified [here](https://forums.docker.com/t/installing-docker-on-windows-10-home/11722).

## Running it

First permit your operating system to run these scripts:

```
chmod a+x ./start-db.sh
chmod a+x ./stop-db.sh
```

And then to start your PostgreSQL container with your database setup:

```
./start-db.sh
```

And to stop it:

```
./stop-db.sh
```

## Updating the schema
You can modify the [apollo.sql](apollo.sql) script to add dummy data to your database. Note however that you are required to delete the associated volume after modifying the script to make it work:

```
docker volume rm database_data
```

The `start.sh` and `stop.sh` scripts do this for you as well.
Loading