feat: update liquibase script
This commit is contained in:
@@ -5,4 +5,8 @@
|
|||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
|
||||||
<include file="prepare-database.sql" relativeToChangelogFile="true"/>
|
<include file="prepare-database.sql" relativeToChangelogFile="true"/>
|
||||||
<include file="changeset/create-user.xml" relativeToChangelogFile="true"/>
|
<include file="changeset/create-user.xml" relativeToChangelogFile="true"/>
|
||||||
|
<include file="changeset/create-server.xml" relativeToChangelogFile="true"/>
|
||||||
|
<include file="changeset/create-game.xml" relativeToChangelogFile="true"/>
|
||||||
|
<include file="changeset/create-cage.xml" relativeToChangelogFile="true"/>
|
||||||
|
<include file="changeset/create-hamster.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
22
liquibase/changelogs/changeset/create-cage.xml
Normal file
22
liquibase/changelogs/changeset/create-cage.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
|
||||||
|
<changeSet id="add-cage-table" author="kratisto">
|
||||||
|
<createTable tableName="cage">
|
||||||
|
<column name="id" type="uuid" defaultValueComputed="gen_random_uuid()">
|
||||||
|
<constraints nullable="false" unique="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="created_at" type="timestamp" defaultValueComputed="now()">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="updated_at" type="timestamp">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="game_id" type="uuid" >
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
25
liquibase/changelogs/changeset/create-game.xml
Normal file
25
liquibase/changelogs/changeset/create-game.xml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
|
||||||
|
<changeSet id="add-game-table" author="kratisto">
|
||||||
|
<createTable tableName="game">
|
||||||
|
<column name="id" type="uuid" defaultValueComputed="gen_random_uuid()">
|
||||||
|
<constraints nullable="false" unique="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="server_id" type="uuid">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="user_id" type="uuid">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="created_at" type="timestamp" defaultValueComputed="now()">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="updated_at" type="timestamp">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
67
liquibase/changelogs/changeset/create-hamster.xml
Normal file
67
liquibase/changelogs/changeset/create-hamster.xml
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
|
||||||
|
<changeSet id="add-hamster-table" author="kratisto">
|
||||||
|
<createTable tableName="hamster">
|
||||||
|
<column name="id" type="uuid" defaultValueComputed="gen_random_uuid()">
|
||||||
|
<constraints nullable="false" unique="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="created_at" type="timestamp" defaultValueComputed="now()">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="updated_at" type="timestamp">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="name" type="text" >
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="number" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="sexe" type="text">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="age" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="father_id" type="uuid">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="mother_id" type="uuid">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="hunger_level" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="thirst_level" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="weight" type="float">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="height" type="float">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="alive" type="boolean">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="sold" type="boolean">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="gestation" type="boolean">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="gestation_period" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="gestation_cooldown" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="gestation_father_id" type="uuid">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
16
liquibase/changelogs/changeset/create-server.xml
Normal file
16
liquibase/changelogs/changeset/create-server.xml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
|
||||||
|
<changeSet id="add-server-table" author="kratisto">
|
||||||
|
<createTable tableName="server">
|
||||||
|
<column name="id" type="uuid" defaultValueComputed="gen_random_uuid()">
|
||||||
|
<constraints nullable="false" unique="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="name" type="text">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import "Game-tycoon/storage/dao"
|
import "hamster-tycoon/storage/dao"
|
||||||
|
|
||||||
type GameService struct {
|
type GameService struct {
|
||||||
serviceContext
|
serviceContext
|
||||||
|
|||||||
23
storage/dao/fake/database_fake_games.go
Executable file
23
storage/dao/fake/database_fake_games.go
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
package fake
|
||||||
|
|
||||||
|
import "hamster-tycoon/storage/model"
|
||||||
|
|
||||||
|
func (db *DatabaseFake) GetAllGames() ([]*model.Game, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *DatabaseFake) GetGameById(string) (*model.Game, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *DatabaseFake) CreateGame(*model.Game) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *DatabaseFake) DeleteGame(string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *DatabaseFake) UpdateGame(*model.Game) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
package fake
|
|
||||||
@@ -1 +1,23 @@
|
|||||||
package postgresql
|
package postgresql
|
||||||
|
|
||||||
|
import "hamster-tycoon/storage/model"
|
||||||
|
|
||||||
|
func (db *DatabasePostgreSQL) GetAllGames() ([]*model.Game, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *DatabasePostgreSQL) GetGameById(string) (*model.Game, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *DatabasePostgreSQL) CreateGame(*model.Game) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *DatabasePostgreSQL) DeleteGame(string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *DatabasePostgreSQL) UpdateGame(*model.Game) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package model
|
|||||||
|
|
||||||
type Game struct {
|
type Game struct {
|
||||||
ID string `json:"game_id"`
|
ID string `json:"game_id"`
|
||||||
|
User User `json:"-"`
|
||||||
Server Server `json:"server"`
|
Server Server `json:"server"`
|
||||||
Cages []*Cage `json:"cages"`
|
Cages []*Cage `json:"cages"`
|
||||||
SoldHamster []*Hamster `json:"sold_hamsters"`
|
SoldHamster []*Hamster `json:"sold_hamsters"`
|
||||||
|
|||||||
Reference in New Issue
Block a user