diff --git a/bluevsred_client/lib/src/protocol/protocol.dart b/bluevsred_client/lib/src/protocol/protocol.dart index e3bdd29..31bfbb4 100644 --- a/bluevsred_client/lib/src/protocol/protocol.dart +++ b/bluevsred_client/lib/src/protocol/protocol.dart @@ -15,11 +15,13 @@ import 'battle_map_db.dart' as _i3; import 'game_player_db.dart' as _i4; import 'team_db.dart' as _i5; import 'troop_db.dart' as _i6; +import 'troop_type.dart' as _i7; export 'battle_db.dart'; export 'battle_map_db.dart'; export 'game_player_db.dart'; export 'team_db.dart'; export 'troop_db.dart'; +export 'troop_type.dart'; export 'client.dart'; class Protocol extends _i1.SerializationManager { @@ -55,6 +57,9 @@ class Protocol extends _i1.SerializationManager { if (t == _i6.TroopDb) { return _i6.TroopDb.fromJson(data, this) as T; } + if (t == _i7.TroopType) { + return _i7.TroopType.fromJson(data) as T; + } if (t == _i1.getType<_i2.BattleDb?>()) { return (data != null ? _i2.BattleDb.fromJson(data, this) : null) as T; } @@ -70,6 +75,9 @@ class Protocol extends _i1.SerializationManager { if (t == _i1.getType<_i6.TroopDb?>()) { return (data != null ? _i6.TroopDb.fromJson(data, this) : null) as T; } + if (t == _i1.getType<_i7.TroopType?>()) { + return (data != null ? _i7.TroopType.fromJson(data) : null) as T; + } return super.deserialize(data, t); } @@ -90,6 +98,9 @@ class Protocol extends _i1.SerializationManager { if (data is _i6.TroopDb) { return 'TroopDb'; } + if (data is _i7.TroopType) { + return 'TroopType'; + } return super.getClassNameForObject(data); } @@ -110,6 +121,9 @@ class Protocol extends _i1.SerializationManager { if (data['className'] == 'TroopDb') { return deserialize<_i6.TroopDb>(data['data']); } + if (data['className'] == 'TroopType') { + return deserialize<_i7.TroopType>(data['data']); + } return super.deserializeByClassName(data); } } diff --git a/bluevsred_client/lib/src/protocol/troop_db.dart b/bluevsred_client/lib/src/protocol/troop_db.dart index 86b878b..8dc4790 100644 --- a/bluevsred_client/lib/src/protocol/troop_db.dart +++ b/bluevsred_client/lib/src/protocol/troop_db.dart @@ -9,16 +9,19 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:serverpod_client/serverpod_client.dart' as _i1; +import 'protocol.dart' as _i2; abstract class TroopDb extends _i1.SerializableEntity { TroopDb._({ this.id, - required this.path, + required this.troopType, + required this.actionPoints, }); factory TroopDb({ int? id, - required String path, + required _i2.TroopType troopType, + required double actionPoints, }) = _TroopDbImpl; factory TroopDb.fromJson( @@ -27,7 +30,10 @@ abstract class TroopDb extends _i1.SerializableEntity { ) { return TroopDb( id: serializationManager.deserialize(jsonSerialization['id']), - path: serializationManager.deserialize(jsonSerialization['path']), + troopType: serializationManager + .deserialize<_i2.TroopType>(jsonSerialization['troopType']), + actionPoints: serializationManager + .deserialize(jsonSerialization['actionPoints']), ); } @@ -36,17 +42,21 @@ abstract class TroopDb extends _i1.SerializableEntity { /// the id will be null. int? id; - String path; + _i2.TroopType troopType; + + double actionPoints; TroopDb copyWith({ int? id, - String? path, + _i2.TroopType? troopType, + double? actionPoints, }); @override Map toJson() { return { if (id != null) 'id': id, - 'path': path, + 'troopType': troopType.toJson(), + 'actionPoints': actionPoints, }; } } @@ -56,20 +66,24 @@ class _Undefined {} class _TroopDbImpl extends TroopDb { _TroopDbImpl({ int? id, - required String path, + required _i2.TroopType troopType, + required double actionPoints, }) : super._( id: id, - path: path, + troopType: troopType, + actionPoints: actionPoints, ); @override TroopDb copyWith({ Object? id = _Undefined, - String? path, + _i2.TroopType? troopType, + double? actionPoints, }) { return TroopDb( id: id is int? ? id : this.id, - path: path ?? this.path, + troopType: troopType ?? this.troopType, + actionPoints: actionPoints ?? this.actionPoints, ); } } diff --git a/bluevsred_client/lib/src/protocol/troop_type.dart b/bluevsred_client/lib/src/protocol/troop_type.dart new file mode 100644 index 0000000..8ccc67c --- /dev/null +++ b/bluevsred_client/lib/src/protocol/troop_type.dart @@ -0,0 +1,29 @@ +/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ +/* To generate run: "serverpod generate" */ + +// ignore_for_file: library_private_types_in_public_api +// ignore_for_file: public_member_api_docs +// ignore_for_file: implementation_imports +// ignore_for_file: use_super_parameters +// ignore_for_file: type_literal_in_constant_pattern + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:serverpod_client/serverpod_client.dart' as _i1; + +enum TroopType with _i1.SerializableEntity { + commander; + + static TroopType? fromJson(String name) { + switch (name) { + case 'commander': + return commander; + default: + return null; + } + } + + @override + String toJson() => name; + @override + String toString() => toJson(); +} diff --git a/bluevsred_flutter/lib/player/active_game_player_troops.dart b/bluevsred_flutter/lib/player/active_game_player_troops.dart new file mode 100644 index 0000000..4075db1 --- /dev/null +++ b/bluevsred_flutter/lib/player/active_game_player_troops.dart @@ -0,0 +1,23 @@ +import 'package:bluevsred_shared/bluesvsred_shared.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; + +part 'active_game_player_troops.g.dart'; + +@riverpod +class ActiveGamePlayerTroops extends _$ActiveGamePlayerTroops { + // ActiveGamePlayerTroops._(); + @override + Future> build({required Set troops}) async { + return troops; + } + + void addTroops({required List newTroops}) { + this. + state + if (state.value != null) { + state.value!.addAll(newTroops); + } else { + state.value => newTroops; + } + } +} diff --git a/bluevsred_flutter/lib/player/active_game_player_troops.g.dart b/bluevsred_flutter/lib/player/active_game_player_troops.g.dart new file mode 100644 index 0000000..33cfc92 --- /dev/null +++ b/bluevsred_flutter/lib/player/active_game_player_troops.g.dart @@ -0,0 +1,177 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'active_game_player_troops.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$activeGamePlayerTroopsHash() => + r'73b3049bb702ded10d600c481202a379d91f04d1'; + +/// Copied from Dart SDK +class _SystemHash { + _SystemHash._(); + + static int combine(int hash, int value) { + // ignore: parameter_assignments + hash = 0x1fffffff & (hash + value); + // ignore: parameter_assignments + hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); + return hash ^ (hash >> 6); + } + + static int finish(int hash) { + // ignore: parameter_assignments + hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); + // ignore: parameter_assignments + hash = hash ^ (hash >> 11); + return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); + } +} + +abstract class _$ActiveGamePlayerTroops + extends BuildlessAutoDisposeAsyncNotifier> { + late final Set troops; + + FutureOr> build({ + required Set troops, + }); +} + +/// See also [ActiveGamePlayerTroops]. +@ProviderFor(ActiveGamePlayerTroops) +const activeGamePlayerTroopsProvider = ActiveGamePlayerTroopsFamily(); + +/// See also [ActiveGamePlayerTroops]. +class ActiveGamePlayerTroopsFamily extends Family>> { + /// See also [ActiveGamePlayerTroops]. + const ActiveGamePlayerTroopsFamily(); + + /// See also [ActiveGamePlayerTroops]. + ActiveGamePlayerTroopsProvider call({ + required Set troops, + }) { + return ActiveGamePlayerTroopsProvider( + troops: troops, + ); + } + + @override + ActiveGamePlayerTroopsProvider getProviderOverride( + covariant ActiveGamePlayerTroopsProvider provider, + ) { + return call( + troops: provider.troops, + ); + } + + static const Iterable? _dependencies = null; + + @override + Iterable? get dependencies => _dependencies; + + static const Iterable? _allTransitiveDependencies = null; + + @override + Iterable? get allTransitiveDependencies => + _allTransitiveDependencies; + + @override + String? get name => r'activeGamePlayerTroopsProvider'; +} + +/// See also [ActiveGamePlayerTroops]. +class ActiveGamePlayerTroopsProvider + extends AutoDisposeAsyncNotifierProviderImpl> { + /// See also [ActiveGamePlayerTroops]. + ActiveGamePlayerTroopsProvider({ + required Set troops, + }) : this._internal( + () => ActiveGamePlayerTroops()..troops = troops, + from: activeGamePlayerTroopsProvider, + name: r'activeGamePlayerTroopsProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') + ? null + : _$activeGamePlayerTroopsHash, + dependencies: ActiveGamePlayerTroopsFamily._dependencies, + allTransitiveDependencies: + ActiveGamePlayerTroopsFamily._allTransitiveDependencies, + troops: troops, + ); + + ActiveGamePlayerTroopsProvider._internal( + super._createNotifier, { + required super.name, + required super.dependencies, + required super.allTransitiveDependencies, + required super.debugGetCreateSourceHash, + required super.from, + required this.troops, + }) : super.internal(); + + final Set troops; + + @override + FutureOr> runNotifierBuild( + covariant ActiveGamePlayerTroops notifier, + ) { + return notifier.build( + troops: troops, + ); + } + + @override + Override overrideWith(ActiveGamePlayerTroops Function() create) { + return ProviderOverride( + origin: this, + override: ActiveGamePlayerTroopsProvider._internal( + () => create()..troops = troops, + from: from, + name: null, + dependencies: null, + allTransitiveDependencies: null, + debugGetCreateSourceHash: null, + troops: troops, + ), + ); + } + + @override + AutoDisposeAsyncNotifierProviderElement> + createElement() { + return _ActiveGamePlayerTroopsProviderElement(this); + } + + @override + bool operator ==(Object other) { + return other is ActiveGamePlayerTroopsProvider && other.troops == troops; + } + + @override + int get hashCode { + var hash = _SystemHash.combine(0, runtimeType.hashCode); + hash = _SystemHash.combine(hash, troops.hashCode); + + return _SystemHash.finish(hash); + } +} + +mixin ActiveGamePlayerTroopsRef + on AutoDisposeAsyncNotifierProviderRef> { + /// The parameter `troops` of this provider. + Set get troops; +} + +class _ActiveGamePlayerTroopsProviderElement + extends AutoDisposeAsyncNotifierProviderElement> with ActiveGamePlayerTroopsRef { + _ActiveGamePlayerTroopsProviderElement(super.provider); + + @override + Set get troops => (origin as ActiveGamePlayerTroopsProvider).troops; +} +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/bluevsred_flutter/lib/player/create_player.dart b/bluevsred_flutter/lib/player/create_player.dart new file mode 100644 index 0000000..0667cd0 --- /dev/null +++ b/bluevsred_flutter/lib/player/create_player.dart @@ -0,0 +1,21 @@ +import 'package:bluevsred_client/bluevsred_client.dart'; +import 'package:bluevsred_flutter/player/active_game_player_troops.dart'; +import 'package:bluevsred_shared/bluesvsred_shared.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import 'active_game_player.dart'; + +Future createGamePlayer( + {required String gamePlayerName, + required ProviderContainer container}) async { + final gamePlayerProvider = activeGamePlayerProvider(gamePlayerName); + // container.listen(gamePlayerProvider, (previous, next) {}); + final troopsProvider = activeGamePlayerTroopsProvider(troops: const {}); + // container.listen(troopsProvider, (previous, next) {}); + + container.read(troopsProvider).value!.addTroops(newTroops: [ + Troop( + troopDb: TroopDb(troopType: TroopType.commander, actionPoints: 10), + gamePlayer: container.read(gamePlayerProvider).value!), + ]); +} diff --git a/bluevsred_flutter/test/game_player_test.dart b/bluevsred_flutter/test/game_player_test.dart index 5d692ef..ba2eb93 100644 --- a/bluevsred_flutter/test/game_player_test.dart +++ b/bluevsred_flutter/test/game_player_test.dart @@ -1,5 +1,9 @@ // import 'package:bluevsred_shared/src/game_player/game_player.dart'; +import 'package:bluevsred_client/bluevsred_client.dart'; import 'package:bluevsred_flutter/player/active_game_player.dart'; +import 'package:bluevsred_flutter/player/active_game_player_troops.dart'; +import 'package:bluevsred_flutter/player/create_player.dart'; +import 'package:bluevsred_shared/bluesvsred_shared.dart'; import 'package:test/test.dart'; import 'provider_container.dart'; @@ -9,20 +13,27 @@ void main() { test('When a player is created its name begin by given string ', () async { final container = createContainer(); const expectedName = 'given name'; - var state = container.read(activeGamePlayerProvider(expectedName).notifier); + var state = + container.read(activeGamePlayerProvider(expectedName).notifier); expect((await state.future).name, equals(expectedName)); }); - test('when game player is created, he gets a commander troop', () { - // Here comes the need of state management system - bool isPlayerInTheList = false; - - /// check player is not in inital list - expect(isPlayerInTheList, equals(false)); + test('when game player is created, he gets a commander troop', () async { + final container = createContainer(); + const expectedName = 'given name'; + final troopsProvider = activeGamePlayerTroopsProvider(troops: {}); + container.listen(troopsProvider, (previous, next) {}); + expectLater(container.read(troopsProvider.future), completion({})); - /// Add new player to the list - isPlayerInTheList = true; - expect(isPlayerInTheList, equals(true)); + createGamePlayer(gamePlayerName: expectedName, container: container); + expectLater( + container.read(troopsProvider.future), + completion({ + Troop( + troopDb: + TroopDb(troopType: TroopType.commander, actionPoints: 10), + gamePlayer: GamePlayer(name: expectedName)) + })); }); // test('when game player is created, his first commander is created', () { diff --git a/bluevsred_server/lib/src/generated/protocol.dart b/bluevsred_server/lib/src/generated/protocol.dart index 0ef7221..8b5997f 100644 --- a/bluevsred_server/lib/src/generated/protocol.dart +++ b/bluevsred_server/lib/src/generated/protocol.dart @@ -16,11 +16,13 @@ import 'battle_map_db.dart' as _i4; import 'game_player_db.dart' as _i5; import 'team_db.dart' as _i6; import 'troop_db.dart' as _i7; +import 'troop_type.dart' as _i8; export 'battle_db.dart'; export 'battle_map_db.dart'; export 'game_player_db.dart'; export 'team_db.dart'; export 'troop_db.dart'; +export 'troop_type.dart'; class Protocol extends _i1.SerializationManagerServer { Protocol._(); @@ -222,10 +224,16 @@ class Protocol extends _i1.SerializationManagerServer { columnDefault: 'nextval(\'troop_id_seq\'::regclass)', ), _i2.ColumnDefinition( - name: 'path', + name: 'troopType', columnType: _i2.ColumnType.text, isNullable: false, - dartType: 'String', + dartType: 'protocol:TroopType', + ), + _i2.ColumnDefinition( + name: 'actionPoints', + columnType: _i2.ColumnType.doublePrecision, + isNullable: false, + dartType: 'double', ), ], foreignKeys: [], @@ -273,6 +281,9 @@ class Protocol extends _i1.SerializationManagerServer { if (t == _i7.TroopDb) { return _i7.TroopDb.fromJson(data, this) as T; } + if (t == _i8.TroopType) { + return _i8.TroopType.fromJson(data) as T; + } if (t == _i1.getType<_i3.BattleDb?>()) { return (data != null ? _i3.BattleDb.fromJson(data, this) : null) as T; } @@ -288,6 +299,9 @@ class Protocol extends _i1.SerializationManagerServer { if (t == _i1.getType<_i7.TroopDb?>()) { return (data != null ? _i7.TroopDb.fromJson(data, this) : null) as T; } + if (t == _i1.getType<_i8.TroopType?>()) { + return (data != null ? _i8.TroopType.fromJson(data) : null) as T; + } try { return _i2.Protocol().deserialize(data, t); } catch (_) {} @@ -311,6 +325,9 @@ class Protocol extends _i1.SerializationManagerServer { if (data is _i7.TroopDb) { return 'TroopDb'; } + if (data is _i8.TroopType) { + return 'TroopType'; + } return super.getClassNameForObject(data); } @@ -331,6 +348,9 @@ class Protocol extends _i1.SerializationManagerServer { if (data['className'] == 'TroopDb') { return deserialize<_i7.TroopDb>(data['data']); } + if (data['className'] == 'TroopType') { + return deserialize<_i8.TroopType>(data['data']); + } return super.deserializeByClassName(data); } diff --git a/bluevsred_server/lib/src/generated/troop_db.dart b/bluevsred_server/lib/src/generated/troop_db.dart index d8b0b5b..fe50afe 100644 --- a/bluevsred_server/lib/src/generated/troop_db.dart +++ b/bluevsred_server/lib/src/generated/troop_db.dart @@ -9,16 +9,19 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:serverpod/serverpod.dart' as _i1; +import 'protocol.dart' as _i2; abstract class TroopDb extends _i1.TableRow { TroopDb._({ int? id, - required this.path, + required this.troopType, + required this.actionPoints, }) : super(id); factory TroopDb({ int? id, - required String path, + required _i2.TroopType troopType, + required double actionPoints, }) = _TroopDbImpl; factory TroopDb.fromJson( @@ -27,7 +30,10 @@ abstract class TroopDb extends _i1.TableRow { ) { return TroopDb( id: serializationManager.deserialize(jsonSerialization['id']), - path: serializationManager.deserialize(jsonSerialization['path']), + troopType: serializationManager + .deserialize<_i2.TroopType>(jsonSerialization['troopType']), + actionPoints: serializationManager + .deserialize(jsonSerialization['actionPoints']), ); } @@ -35,20 +41,24 @@ abstract class TroopDb extends _i1.TableRow { static const db = TroopDbRepository._(); - String path; + _i2.TroopType troopType; + + double actionPoints; @override _i1.Table get table => t; TroopDb copyWith({ int? id, - String? path, + _i2.TroopType? troopType, + double? actionPoints, }); @override Map toJson() { return { if (id != null) 'id': id, - 'path': path, + 'troopType': troopType.toJson(), + 'actionPoints': actionPoints, }; } @@ -57,7 +67,8 @@ abstract class TroopDb extends _i1.TableRow { Map toJsonForDatabase() { return { 'id': id, - 'path': path, + 'troopType': troopType, + 'actionPoints': actionPoints, }; } @@ -65,7 +76,8 @@ abstract class TroopDb extends _i1.TableRow { Map allToJson() { return { if (id != null) 'id': id, - 'path': path, + 'troopType': troopType.toJson(), + 'actionPoints': actionPoints, }; } @@ -79,8 +91,11 @@ abstract class TroopDb extends _i1.TableRow { case 'id': id = value; return; - case 'path': - path = value; + case 'troopType': + troopType = value; + return; + case 'actionPoints': + actionPoints = value; return; default: throw UnimplementedError(); @@ -234,38 +249,50 @@ class _Undefined {} class _TroopDbImpl extends TroopDb { _TroopDbImpl({ int? id, - required String path, + required _i2.TroopType troopType, + required double actionPoints, }) : super._( id: id, - path: path, + troopType: troopType, + actionPoints: actionPoints, ); @override TroopDb copyWith({ Object? id = _Undefined, - String? path, + _i2.TroopType? troopType, + double? actionPoints, }) { return TroopDb( id: id is int? ? id : this.id, - path: path ?? this.path, + troopType: troopType ?? this.troopType, + actionPoints: actionPoints ?? this.actionPoints, ); } } class TroopDbTable extends _i1.Table { TroopDbTable({super.tableRelation}) : super(tableName: 'troop') { - path = _i1.ColumnString( - 'path', + troopType = _i1.ColumnEnum( + 'troopType', + this, + _i1.EnumSerialization.byName, + ); + actionPoints = _i1.ColumnDouble( + 'actionPoints', this, ); } - late final _i1.ColumnString path; + late final _i1.ColumnEnum<_i2.TroopType> troopType; + + late final _i1.ColumnDouble actionPoints; @override List<_i1.Column> get columns => [ id, - path, + troopType, + actionPoints, ]; } diff --git a/bluevsred_server/lib/src/generated/troop_type.dart b/bluevsred_server/lib/src/generated/troop_type.dart new file mode 100644 index 0000000..46b5c2e --- /dev/null +++ b/bluevsred_server/lib/src/generated/troop_type.dart @@ -0,0 +1,29 @@ +/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ +/* To generate run: "serverpod generate" */ + +// ignore_for_file: library_private_types_in_public_api +// ignore_for_file: public_member_api_docs +// ignore_for_file: implementation_imports +// ignore_for_file: use_super_parameters +// ignore_for_file: type_literal_in_constant_pattern + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:serverpod/serverpod.dart' as _i1; + +enum TroopType with _i1.SerializableEntity { + commander; + + static TroopType? fromJson(String name) { + switch (name) { + case 'commander': + return commander; + default: + return null; + } + } + + @override + String toJson() => name; + @override + String toString() => toJson(); +} diff --git a/bluevsred_server/lib/src/models/troop_db.yaml b/bluevsred_server/lib/src/models/troop_db.yaml index 802d842..5a28730 100644 --- a/bluevsred_server/lib/src/models/troop_db.yaml +++ b/bluevsred_server/lib/src/models/troop_db.yaml @@ -1,4 +1,5 @@ class: TroopDb table: troop fields: - path: String \ No newline at end of file + troopType: TroopType + actionPoints: double \ No newline at end of file diff --git a/bluevsred_server/lib/src/models/troop_type.yaml b/bluevsred_server/lib/src/models/troop_type.yaml new file mode 100644 index 0000000..78032f3 --- /dev/null +++ b/bluevsred_server/lib/src/models/troop_type.yaml @@ -0,0 +1,4 @@ +enum: TroopType +serialized: byName +values: + - commander \ No newline at end of file diff --git a/bluevsred_server/migrations/20240412073903562/definition.json b/bluevsred_server/migrations/20240412073903562/definition.json new file mode 100644 index 0000000..ce75112 --- /dev/null +++ b/bluevsred_server/migrations/20240412073903562/definition.json @@ -0,0 +1,1435 @@ +{ + "moduleName": "bluevsred", + "tables": [ + { + "name": "battle", + "dartName": "BattleDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('battle_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "creationDate", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "startDate", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "maxActionPoints", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "actionPointsRecoveryRate", + "columnType": 3, + "isNullable": false, + "dartType": "double" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "battle_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "player", + "dartName": "GamePlayerDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('player_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "player_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "talle_map", + "dartName": "BattleMapDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('talle_map_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "talle_map_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "team", + "dartName": "TeamDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('team_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "colorCode", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "team_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "troop", + "dartName": "TroopDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('troop_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "troopType", + "columnType": 0, + "isNullable": false, + "dartType": "protocol:TroopType" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "troop_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "serverpod_auth_key", + "dartName": "AuthKey", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_auth_key_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "userId", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "hash", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "scopeNames", + "columnType": 8, + "isNullable": false, + "dartType": "List" + }, + { + "name": "method", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_auth_key_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_auth_key_userId_idx", + "elements": [ + { + "type": 0, + "definition": "userId" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_cloud_storage", + "dartName": "CloudStorageEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_cloud_storage_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "storageId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "addedTime", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "expiration", + "columnType": 4, + "isNullable": true, + "dartType": "DateTime?" + }, + { + "name": "byteData", + "columnType": 5, + "isNullable": false, + "dartType": "dart:typed_data:ByteData" + }, + { + "name": "verified", + "columnType": 1, + "isNullable": false, + "dartType": "bool" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_cloud_storage_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_cloud_storage_path_idx", + "elements": [ + { + "type": 0, + "definition": "storageId" + }, + { + "type": 0, + "definition": "path" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + }, + { + "indexName": "serverpod_cloud_storage_expiration", + "elements": [ + { + "type": 0, + "definition": "expiration" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_cloud_storage_direct_upload", + "dartName": "CloudStorageDirectUploadEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_cloud_storage_direct_upload_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "storageId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "expiration", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "authKey", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_cloud_storage_direct_upload_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_cloud_storage_direct_upload_storage_path", + "elements": [ + { + "type": 0, + "definition": "storageId" + }, + { + "type": 0, + "definition": "path" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_future_call", + "dartName": "FutureCallEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_future_call_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "time", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "serializedObject", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "identifier", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_future_call_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_future_call_time_idx", + "elements": [ + { + "type": 0, + "definition": "time" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + }, + { + "indexName": "serverpod_future_call_serverId_idx", + "elements": [ + { + "type": 0, + "definition": "serverId" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + }, + { + "indexName": "serverpod_future_call_identifier_idx", + "elements": [ + { + "type": 0, + "definition": "identifier" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_health_connection_info", + "dartName": "ServerHealthConnectionInfo", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_health_connection_info_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "timestamp", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "active", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "closing", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "idle", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "granularity", + "columnType": 2, + "isNullable": false, + "dartType": "int" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_health_connection_info_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_health_connection_info_timestamp_idx", + "elements": [ + { + "type": 0, + "definition": "timestamp" + }, + { + "type": 0, + "definition": "serverId" + }, + { + "type": 0, + "definition": "granularity" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_health_metric", + "dartName": "ServerHealthMetric", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_health_metric_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "timestamp", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "isHealthy", + "columnType": 1, + "isNullable": false, + "dartType": "bool" + }, + { + "name": "value", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "granularity", + "columnType": 2, + "isNullable": false, + "dartType": "int" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_health_metric_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_health_metric_timestamp_idx", + "elements": [ + { + "type": 0, + "definition": "timestamp" + }, + { + "type": 0, + "definition": "serverId" + }, + { + "type": 0, + "definition": "name" + }, + { + "type": 0, + "definition": "granularity" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_log", + "dartName": "LogEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_log_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "sessionLogId", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "messageId", + "columnType": 2, + "isNullable": true, + "dartType": "int?" + }, + { + "name": "reference", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "time", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "logLevel", + "columnType": 2, + "isNullable": false, + "dartType": "protocol:LogLevel" + }, + { + "name": "message", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "error", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "stackTrace", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "order", + "columnType": 2, + "isNullable": false, + "dartType": "int" + } + ], + "foreignKeys": [ + { + "constraintName": "serverpod_log_fk_0", + "columns": [ + "sessionLogId" + ], + "referenceTable": "serverpod_session_log", + "referenceTableSchema": "public", + "referenceColumns": [ + "id" + ], + "onUpdate": 3, + "onDelete": 4 + } + ], + "indexes": [ + { + "indexName": "serverpod_log_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_log_sessionLogId_idx", + "elements": [ + { + "type": 0, + "definition": "sessionLogId" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_message_log", + "dartName": "MessageLogEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_message_log_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "sessionLogId", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "messageId", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "endpoint", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "messageName", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "duration", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "error", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "stackTrace", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "slow", + "columnType": 1, + "isNullable": false, + "dartType": "bool" + }, + { + "name": "order", + "columnType": 2, + "isNullable": false, + "dartType": "int" + } + ], + "foreignKeys": [ + { + "constraintName": "serverpod_message_log_fk_0", + "columns": [ + "sessionLogId" + ], + "referenceTable": "serverpod_session_log", + "referenceTableSchema": "public", + "referenceColumns": [ + "id" + ], + "onUpdate": 3, + "onDelete": 4 + } + ], + "indexes": [ + { + "indexName": "serverpod_message_log_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "serverpod_method", + "dartName": "MethodInfo", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_method_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "endpoint", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "method", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_method_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_method_endpoint_method_idx", + "elements": [ + { + "type": 0, + "definition": "endpoint" + }, + { + "type": 0, + "definition": "method" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_migrations", + "dartName": "DatabaseMigrationVersion", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_migrations_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "module", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "version", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "timestamp", + "columnType": 4, + "isNullable": true, + "dartType": "DateTime?" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_migrations_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_migrations_ids", + "elements": [ + { + "type": 0, + "definition": "module" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_query_log", + "dartName": "QueryLogEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_query_log_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "sessionLogId", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "messageId", + "columnType": 2, + "isNullable": true, + "dartType": "int?" + }, + { + "name": "query", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "duration", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "numRows", + "columnType": 2, + "isNullable": true, + "dartType": "int?" + }, + { + "name": "error", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "stackTrace", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "slow", + "columnType": 1, + "isNullable": false, + "dartType": "bool" + }, + { + "name": "order", + "columnType": 2, + "isNullable": false, + "dartType": "int" + } + ], + "foreignKeys": [ + { + "constraintName": "serverpod_query_log_fk_0", + "columns": [ + "sessionLogId" + ], + "referenceTable": "serverpod_session_log", + "referenceTableSchema": "public", + "referenceColumns": [ + "id" + ], + "onUpdate": 3, + "onDelete": 4 + } + ], + "indexes": [ + { + "indexName": "serverpod_query_log_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_query_log_sessionLogId_idx", + "elements": [ + { + "type": 0, + "definition": "sessionLogId" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_readwrite_test", + "dartName": "ReadWriteTestEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_readwrite_test_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "number", + "columnType": 2, + "isNullable": false, + "dartType": "int" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_readwrite_test_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "serverpod_runtime_settings", + "dartName": "RuntimeSettings", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_runtime_settings_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "logSettings", + "columnType": 8, + "isNullable": false, + "dartType": "protocol:LogSettings" + }, + { + "name": "logSettingsOverrides", + "columnType": 8, + "isNullable": false, + "dartType": "List" + }, + { + "name": "logServiceCalls", + "columnType": 1, + "isNullable": false, + "dartType": "bool" + }, + { + "name": "logMalformedCalls", + "columnType": 1, + "isNullable": false, + "dartType": "bool" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_runtime_settings_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "serverpod_session_log", + "dartName": "SessionLogEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_session_log_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "time", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "module", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "endpoint", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "method", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "duration", + "columnType": 3, + "isNullable": true, + "dartType": "double?" + }, + { + "name": "numQueries", + "columnType": 2, + "isNullable": true, + "dartType": "int?" + }, + { + "name": "slow", + "columnType": 1, + "isNullable": true, + "dartType": "bool?" + }, + { + "name": "error", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "stackTrace", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "authenticatedUserId", + "columnType": 2, + "isNullable": true, + "dartType": "int?" + }, + { + "name": "isOpen", + "columnType": 1, + "isNullable": true, + "dartType": "bool?" + }, + { + "name": "touched", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_session_log_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_session_log_serverid_idx", + "elements": [ + { + "type": 0, + "definition": "serverId" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + }, + { + "indexName": "serverpod_session_log_touched_idx", + "elements": [ + { + "type": 0, + "definition": "touched" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + }, + { + "indexName": "serverpod_session_log_isopen_idx", + "elements": [ + { + "type": 0, + "definition": "isOpen" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + } + ], + "installedModules": [ + { + "module": "bluevsred", + "version": "20240412073903562" + }, + { + "module": "serverpod", + "version": "20240115074235544" + } + ], + "migrationApiVersion": 1 +} \ No newline at end of file diff --git a/bluevsred_server/migrations/20240412073903562/definition.sql b/bluevsred_server/migrations/20240412073903562/definition.sql new file mode 100644 index 0000000..a1ac1e6 --- /dev/null +++ b/bluevsred_server/migrations/20240412073903562/definition.sql @@ -0,0 +1,316 @@ +BEGIN; + +-- +-- Class BattleDb as table battle +-- +CREATE TABLE "battle" ( + "id" serial PRIMARY KEY, + "creationDate" timestamp without time zone NOT NULL, + "startDate" timestamp without time zone NOT NULL, + "maxActionPoints" double precision NOT NULL, + "actionPointsRecoveryRate" double precision NOT NULL +); + +-- +-- Class GamePlayerDb as table player +-- +CREATE TABLE "player" ( + "id" serial PRIMARY KEY, + "name" text NOT NULL +); + +-- +-- Class BattleMapDb as table talle_map +-- +CREATE TABLE "talle_map" ( + "id" serial PRIMARY KEY, + "path" text NOT NULL +); + +-- +-- Class TeamDb as table team +-- +CREATE TABLE "team" ( + "id" serial PRIMARY KEY, + "name" text NOT NULL, + "colorCode" text NOT NULL +); + +-- +-- Class TroopDb as table troop +-- +CREATE TABLE "troop" ( + "id" serial PRIMARY KEY, + "path" text NOT NULL, + "troopType" text NOT NULL +); + +-- +-- Class AuthKey as table serverpod_auth_key +-- +CREATE TABLE "serverpod_auth_key" ( + "id" serial PRIMARY KEY, + "userId" integer NOT NULL, + "hash" text NOT NULL, + "scopeNames" json NOT NULL, + "method" text NOT NULL +); + +-- Indexes +CREATE INDEX "serverpod_auth_key_userId_idx" ON "serverpod_auth_key" USING btree ("userId"); + +-- +-- Class CloudStorageEntry as table serverpod_cloud_storage +-- +CREATE TABLE "serverpod_cloud_storage" ( + "id" serial PRIMARY KEY, + "storageId" text NOT NULL, + "path" text NOT NULL, + "addedTime" timestamp without time zone NOT NULL, + "expiration" timestamp without time zone, + "byteData" bytea NOT NULL, + "verified" boolean NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_cloud_storage_path_idx" ON "serverpod_cloud_storage" USING btree ("storageId", "path"); +CREATE INDEX "serverpod_cloud_storage_expiration" ON "serverpod_cloud_storage" USING btree ("expiration"); + +-- +-- Class CloudStorageDirectUploadEntry as table serverpod_cloud_storage_direct_upload +-- +CREATE TABLE "serverpod_cloud_storage_direct_upload" ( + "id" serial PRIMARY KEY, + "storageId" text NOT NULL, + "path" text NOT NULL, + "expiration" timestamp without time zone NOT NULL, + "authKey" text NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_cloud_storage_direct_upload_storage_path" ON "serverpod_cloud_storage_direct_upload" USING btree ("storageId", "path"); + +-- +-- Class FutureCallEntry as table serverpod_future_call +-- +CREATE TABLE "serverpod_future_call" ( + "id" serial PRIMARY KEY, + "name" text NOT NULL, + "time" timestamp without time zone NOT NULL, + "serializedObject" text, + "serverId" text NOT NULL, + "identifier" text +); + +-- Indexes +CREATE INDEX "serverpod_future_call_time_idx" ON "serverpod_future_call" USING btree ("time"); +CREATE INDEX "serverpod_future_call_serverId_idx" ON "serverpod_future_call" USING btree ("serverId"); +CREATE INDEX "serverpod_future_call_identifier_idx" ON "serverpod_future_call" USING btree ("identifier"); + +-- +-- Class ServerHealthConnectionInfo as table serverpod_health_connection_info +-- +CREATE TABLE "serverpod_health_connection_info" ( + "id" serial PRIMARY KEY, + "serverId" text NOT NULL, + "timestamp" timestamp without time zone NOT NULL, + "active" integer NOT NULL, + "closing" integer NOT NULL, + "idle" integer NOT NULL, + "granularity" integer NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_health_connection_info_timestamp_idx" ON "serverpod_health_connection_info" USING btree ("timestamp", "serverId", "granularity"); + +-- +-- Class ServerHealthMetric as table serverpod_health_metric +-- +CREATE TABLE "serverpod_health_metric" ( + "id" serial PRIMARY KEY, + "name" text NOT NULL, + "serverId" text NOT NULL, + "timestamp" timestamp without time zone NOT NULL, + "isHealthy" boolean NOT NULL, + "value" double precision NOT NULL, + "granularity" integer NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_health_metric_timestamp_idx" ON "serverpod_health_metric" USING btree ("timestamp", "serverId", "name", "granularity"); + +-- +-- Class LogEntry as table serverpod_log +-- +CREATE TABLE "serverpod_log" ( + "id" serial PRIMARY KEY, + "sessionLogId" integer NOT NULL, + "messageId" integer, + "reference" text, + "serverId" text NOT NULL, + "time" timestamp without time zone NOT NULL, + "logLevel" integer NOT NULL, + "message" text NOT NULL, + "error" text, + "stackTrace" text, + "order" integer NOT NULL +); + +-- Indexes +CREATE INDEX "serverpod_log_sessionLogId_idx" ON "serverpod_log" USING btree ("sessionLogId"); + +-- +-- Class MessageLogEntry as table serverpod_message_log +-- +CREATE TABLE "serverpod_message_log" ( + "id" serial PRIMARY KEY, + "sessionLogId" integer NOT NULL, + "serverId" text NOT NULL, + "messageId" integer NOT NULL, + "endpoint" text NOT NULL, + "messageName" text NOT NULL, + "duration" double precision NOT NULL, + "error" text, + "stackTrace" text, + "slow" boolean NOT NULL, + "order" integer NOT NULL +); + +-- +-- Class MethodInfo as table serverpod_method +-- +CREATE TABLE "serverpod_method" ( + "id" serial PRIMARY KEY, + "endpoint" text NOT NULL, + "method" text NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_method_endpoint_method_idx" ON "serverpod_method" USING btree ("endpoint", "method"); + +-- +-- Class DatabaseMigrationVersion as table serverpod_migrations +-- +CREATE TABLE "serverpod_migrations" ( + "id" serial PRIMARY KEY, + "module" text NOT NULL, + "version" text NOT NULL, + "timestamp" timestamp without time zone +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_migrations_ids" ON "serverpod_migrations" USING btree ("module"); + +-- +-- Class QueryLogEntry as table serverpod_query_log +-- +CREATE TABLE "serverpod_query_log" ( + "id" serial PRIMARY KEY, + "serverId" text NOT NULL, + "sessionLogId" integer NOT NULL, + "messageId" integer, + "query" text NOT NULL, + "duration" double precision NOT NULL, + "numRows" integer, + "error" text, + "stackTrace" text, + "slow" boolean NOT NULL, + "order" integer NOT NULL +); + +-- Indexes +CREATE INDEX "serverpod_query_log_sessionLogId_idx" ON "serverpod_query_log" USING btree ("sessionLogId"); + +-- +-- Class ReadWriteTestEntry as table serverpod_readwrite_test +-- +CREATE TABLE "serverpod_readwrite_test" ( + "id" serial PRIMARY KEY, + "number" integer NOT NULL +); + +-- +-- Class RuntimeSettings as table serverpod_runtime_settings +-- +CREATE TABLE "serverpod_runtime_settings" ( + "id" serial PRIMARY KEY, + "logSettings" json NOT NULL, + "logSettingsOverrides" json NOT NULL, + "logServiceCalls" boolean NOT NULL, + "logMalformedCalls" boolean NOT NULL +); + +-- +-- Class SessionLogEntry as table serverpod_session_log +-- +CREATE TABLE "serverpod_session_log" ( + "id" serial PRIMARY KEY, + "serverId" text NOT NULL, + "time" timestamp without time zone NOT NULL, + "module" text, + "endpoint" text, + "method" text, + "duration" double precision, + "numQueries" integer, + "slow" boolean, + "error" text, + "stackTrace" text, + "authenticatedUserId" integer, + "isOpen" boolean, + "touched" timestamp without time zone NOT NULL +); + +-- Indexes +CREATE INDEX "serverpod_session_log_serverid_idx" ON "serverpod_session_log" USING btree ("serverId"); +CREATE INDEX "serverpod_session_log_touched_idx" ON "serverpod_session_log" USING btree ("touched"); +CREATE INDEX "serverpod_session_log_isopen_idx" ON "serverpod_session_log" USING btree ("isOpen"); + +-- +-- Foreign relations for "serverpod_log" table +-- +ALTER TABLE ONLY "serverpod_log" + ADD CONSTRAINT "serverpod_log_fk_0" + FOREIGN KEY("sessionLogId") + REFERENCES "serverpod_session_log"("id") + ON DELETE CASCADE + ON UPDATE NO ACTION; + +-- +-- Foreign relations for "serverpod_message_log" table +-- +ALTER TABLE ONLY "serverpod_message_log" + ADD CONSTRAINT "serverpod_message_log_fk_0" + FOREIGN KEY("sessionLogId") + REFERENCES "serverpod_session_log"("id") + ON DELETE CASCADE + ON UPDATE NO ACTION; + +-- +-- Foreign relations for "serverpod_query_log" table +-- +ALTER TABLE ONLY "serverpod_query_log" + ADD CONSTRAINT "serverpod_query_log_fk_0" + FOREIGN KEY("sessionLogId") + REFERENCES "serverpod_session_log"("id") + ON DELETE CASCADE + ON UPDATE NO ACTION; + + +-- +-- MIGRATION VERSION FOR bluevsred +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('bluevsred', '20240412073903562', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240412073903562', "timestamp" = now(); + +-- +-- MIGRATION VERSION FOR serverpod +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('serverpod', '20240115074235544', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240115074235544', "timestamp" = now(); + + +COMMIT; diff --git a/bluevsred_server/migrations/20240412073903562/definition_project.json b/bluevsred_server/migrations/20240412073903562/definition_project.json new file mode 100644 index 0000000..04f419a --- /dev/null +++ b/bluevsred_server/migrations/20240412073903562/definition_project.json @@ -0,0 +1,231 @@ +{ + "moduleName": "bluevsred", + "tables": [ + { + "name": "battle", + "dartName": "BattleDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('battle_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "creationDate", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "startDate", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "maxActionPoints", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "actionPointsRecoveryRate", + "columnType": 3, + "isNullable": false, + "dartType": "double" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "battle_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "player", + "dartName": "GamePlayerDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('player_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "player_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "talle_map", + "dartName": "BattleMapDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('talle_map_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "talle_map_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "team", + "dartName": "TeamDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('team_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "colorCode", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "team_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "troop", + "dartName": "TroopDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('troop_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "troopType", + "columnType": 0, + "isNullable": false, + "dartType": "protocol:TroopType" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "troop_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + } + ], + "installedModules": [ + { + "module": "serverpod", + "version": "20240115074235544" + }, + { + "module": "bluevsred", + "version": "20240403080154821" + } + ], + "migrationApiVersion": 1 +} \ No newline at end of file diff --git a/bluevsred_server/migrations/20240412073903562/migration.json b/bluevsred_server/migrations/20240412073903562/migration.json new file mode 100644 index 0000000..7e9ecc5 --- /dev/null +++ b/bluevsred_server/migrations/20240412073903562/migration.json @@ -0,0 +1,248 @@ +{ + "actions": [ + { + "type": "deleteTable", + "deleteTable": "example" + }, + { + "type": "createTable", + "createTable": { + "name": "battle", + "dartName": "BattleDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('battle_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "creationDate", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "startDate", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "maxActionPoints", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "actionPointsRecoveryRate", + "columnType": 3, + "isNullable": false, + "dartType": "double" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "battle_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + } + }, + { + "type": "createTable", + "createTable": { + "name": "player", + "dartName": "GamePlayerDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('player_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "player_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + } + }, + { + "type": "createTable", + "createTable": { + "name": "talle_map", + "dartName": "BattleMapDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('talle_map_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "talle_map_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + } + }, + { + "type": "createTable", + "createTable": { + "name": "team", + "dartName": "TeamDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('team_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "colorCode", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "team_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + } + }, + { + "type": "createTable", + "createTable": { + "name": "troop", + "dartName": "TroopDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('troop_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "troopType", + "columnType": 0, + "isNullable": false, + "dartType": "protocol:TroopType" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "troop_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + } + } + ], + "warnings": [ + { + "type": "tableDropped", + "message": "Table \"example\" will be dropped.", + "table": "example", + "columns": [], + "destrucive": true + } + ], + "migrationApiVersion": 1 +} \ No newline at end of file diff --git a/bluevsred_server/migrations/20240412073903562/migration.sql b/bluevsred_server/migrations/20240412073903562/migration.sql new file mode 100644 index 0000000..c98b7ed --- /dev/null +++ b/bluevsred_server/migrations/20240412073903562/migration.sql @@ -0,0 +1,71 @@ +BEGIN; + +-- +-- ACTION DROP TABLE +-- +DROP TABLE "example" CASCADE; + +-- +-- ACTION CREATE TABLE +-- +CREATE TABLE "battle" ( + "id" serial PRIMARY KEY, + "creationDate" timestamp without time zone NOT NULL, + "startDate" timestamp without time zone NOT NULL, + "maxActionPoints" double precision NOT NULL, + "actionPointsRecoveryRate" double precision NOT NULL +); + +-- +-- ACTION CREATE TABLE +-- +CREATE TABLE "player" ( + "id" serial PRIMARY KEY, + "name" text NOT NULL +); + +-- +-- ACTION CREATE TABLE +-- +CREATE TABLE "talle_map" ( + "id" serial PRIMARY KEY, + "path" text NOT NULL +); + +-- +-- ACTION CREATE TABLE +-- +CREATE TABLE "team" ( + "id" serial PRIMARY KEY, + "name" text NOT NULL, + "colorCode" text NOT NULL +); + +-- +-- ACTION CREATE TABLE +-- +CREATE TABLE "troop" ( + "id" serial PRIMARY KEY, + "path" text NOT NULL, + "troopType" text NOT NULL +); + + +-- +-- MIGRATION VERSION FOR bluevsred +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('bluevsred', '20240412073903562', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240412073903562', "timestamp" = now(); + +-- +-- MIGRATION VERSION FOR serverpod +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('serverpod', '20240115074235544', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240115074235544', "timestamp" = now(); + + +COMMIT; diff --git a/bluevsred_server/migrations/20240412092530655/definition.json b/bluevsred_server/migrations/20240412092530655/definition.json new file mode 100644 index 0000000..e112041 --- /dev/null +++ b/bluevsred_server/migrations/20240412092530655/definition.json @@ -0,0 +1,1435 @@ +{ + "moduleName": "bluevsred", + "tables": [ + { + "name": "battle", + "dartName": "BattleDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('battle_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "creationDate", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "startDate", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "maxActionPoints", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "actionPointsRecoveryRate", + "columnType": 3, + "isNullable": false, + "dartType": "double" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "battle_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "player", + "dartName": "GamePlayerDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('player_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "player_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "talle_map", + "dartName": "BattleMapDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('talle_map_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "talle_map_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "team", + "dartName": "TeamDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('team_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "colorCode", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "team_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "troop", + "dartName": "TroopDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('troop_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "troopType", + "columnType": 0, + "isNullable": false, + "dartType": "protocol:TroopType" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "troop_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "serverpod_auth_key", + "dartName": "AuthKey", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_auth_key_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "userId", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "hash", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "scopeNames", + "columnType": 8, + "isNullable": false, + "dartType": "List" + }, + { + "name": "method", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_auth_key_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_auth_key_userId_idx", + "elements": [ + { + "type": 0, + "definition": "userId" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_cloud_storage", + "dartName": "CloudStorageEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_cloud_storage_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "storageId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "addedTime", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "expiration", + "columnType": 4, + "isNullable": true, + "dartType": "DateTime?" + }, + { + "name": "byteData", + "columnType": 5, + "isNullable": false, + "dartType": "dart:typed_data:ByteData" + }, + { + "name": "verified", + "columnType": 1, + "isNullable": false, + "dartType": "bool" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_cloud_storage_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_cloud_storage_path_idx", + "elements": [ + { + "type": 0, + "definition": "storageId" + }, + { + "type": 0, + "definition": "path" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + }, + { + "indexName": "serverpod_cloud_storage_expiration", + "elements": [ + { + "type": 0, + "definition": "expiration" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_cloud_storage_direct_upload", + "dartName": "CloudStorageDirectUploadEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_cloud_storage_direct_upload_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "storageId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "expiration", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "authKey", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_cloud_storage_direct_upload_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_cloud_storage_direct_upload_storage_path", + "elements": [ + { + "type": 0, + "definition": "storageId" + }, + { + "type": 0, + "definition": "path" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_future_call", + "dartName": "FutureCallEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_future_call_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "time", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "serializedObject", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "identifier", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_future_call_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_future_call_time_idx", + "elements": [ + { + "type": 0, + "definition": "time" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + }, + { + "indexName": "serverpod_future_call_serverId_idx", + "elements": [ + { + "type": 0, + "definition": "serverId" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + }, + { + "indexName": "serverpod_future_call_identifier_idx", + "elements": [ + { + "type": 0, + "definition": "identifier" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_health_connection_info", + "dartName": "ServerHealthConnectionInfo", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_health_connection_info_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "timestamp", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "active", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "closing", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "idle", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "granularity", + "columnType": 2, + "isNullable": false, + "dartType": "int" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_health_connection_info_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_health_connection_info_timestamp_idx", + "elements": [ + { + "type": 0, + "definition": "timestamp" + }, + { + "type": 0, + "definition": "serverId" + }, + { + "type": 0, + "definition": "granularity" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_health_metric", + "dartName": "ServerHealthMetric", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_health_metric_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "timestamp", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "isHealthy", + "columnType": 1, + "isNullable": false, + "dartType": "bool" + }, + { + "name": "value", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "granularity", + "columnType": 2, + "isNullable": false, + "dartType": "int" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_health_metric_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_health_metric_timestamp_idx", + "elements": [ + { + "type": 0, + "definition": "timestamp" + }, + { + "type": 0, + "definition": "serverId" + }, + { + "type": 0, + "definition": "name" + }, + { + "type": 0, + "definition": "granularity" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_log", + "dartName": "LogEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_log_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "sessionLogId", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "messageId", + "columnType": 2, + "isNullable": true, + "dartType": "int?" + }, + { + "name": "reference", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "time", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "logLevel", + "columnType": 2, + "isNullable": false, + "dartType": "protocol:LogLevel" + }, + { + "name": "message", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "error", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "stackTrace", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "order", + "columnType": 2, + "isNullable": false, + "dartType": "int" + } + ], + "foreignKeys": [ + { + "constraintName": "serverpod_log_fk_0", + "columns": [ + "sessionLogId" + ], + "referenceTable": "serverpod_session_log", + "referenceTableSchema": "public", + "referenceColumns": [ + "id" + ], + "onUpdate": 3, + "onDelete": 4 + } + ], + "indexes": [ + { + "indexName": "serverpod_log_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_log_sessionLogId_idx", + "elements": [ + { + "type": 0, + "definition": "sessionLogId" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_message_log", + "dartName": "MessageLogEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_message_log_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "sessionLogId", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "messageId", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "endpoint", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "messageName", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "duration", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "error", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "stackTrace", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "slow", + "columnType": 1, + "isNullable": false, + "dartType": "bool" + }, + { + "name": "order", + "columnType": 2, + "isNullable": false, + "dartType": "int" + } + ], + "foreignKeys": [ + { + "constraintName": "serverpod_message_log_fk_0", + "columns": [ + "sessionLogId" + ], + "referenceTable": "serverpod_session_log", + "referenceTableSchema": "public", + "referenceColumns": [ + "id" + ], + "onUpdate": 3, + "onDelete": 4 + } + ], + "indexes": [ + { + "indexName": "serverpod_message_log_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "serverpod_method", + "dartName": "MethodInfo", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_method_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "endpoint", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "method", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_method_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_method_endpoint_method_idx", + "elements": [ + { + "type": 0, + "definition": "endpoint" + }, + { + "type": 0, + "definition": "method" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_migrations", + "dartName": "DatabaseMigrationVersion", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_migrations_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "module", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "version", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "timestamp", + "columnType": 4, + "isNullable": true, + "dartType": "DateTime?" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_migrations_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_migrations_ids", + "elements": [ + { + "type": 0, + "definition": "module" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_query_log", + "dartName": "QueryLogEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_query_log_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "sessionLogId", + "columnType": 2, + "isNullable": false, + "dartType": "int" + }, + { + "name": "messageId", + "columnType": 2, + "isNullable": true, + "dartType": "int?" + }, + { + "name": "query", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "duration", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "numRows", + "columnType": 2, + "isNullable": true, + "dartType": "int?" + }, + { + "name": "error", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "stackTrace", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "slow", + "columnType": 1, + "isNullable": false, + "dartType": "bool" + }, + { + "name": "order", + "columnType": 2, + "isNullable": false, + "dartType": "int" + } + ], + "foreignKeys": [ + { + "constraintName": "serverpod_query_log_fk_0", + "columns": [ + "sessionLogId" + ], + "referenceTable": "serverpod_session_log", + "referenceTableSchema": "public", + "referenceColumns": [ + "id" + ], + "onUpdate": 3, + "onDelete": 4 + } + ], + "indexes": [ + { + "indexName": "serverpod_query_log_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_query_log_sessionLogId_idx", + "elements": [ + { + "type": 0, + "definition": "sessionLogId" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_readwrite_test", + "dartName": "ReadWriteTestEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_readwrite_test_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "number", + "columnType": 2, + "isNullable": false, + "dartType": "int" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_readwrite_test_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "serverpod_runtime_settings", + "dartName": "RuntimeSettings", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_runtime_settings_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "logSettings", + "columnType": 8, + "isNullable": false, + "dartType": "protocol:LogSettings" + }, + { + "name": "logSettingsOverrides", + "columnType": 8, + "isNullable": false, + "dartType": "List" + }, + { + "name": "logServiceCalls", + "columnType": 1, + "isNullable": false, + "dartType": "bool" + }, + { + "name": "logMalformedCalls", + "columnType": 1, + "isNullable": false, + "dartType": "bool" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_runtime_settings_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "serverpod_session_log", + "dartName": "SessionLogEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('serverpod_session_log_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "time", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "module", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "endpoint", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "method", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "duration", + "columnType": 3, + "isNullable": true, + "dartType": "double?" + }, + { + "name": "numQueries", + "columnType": 2, + "isNullable": true, + "dartType": "int?" + }, + { + "name": "slow", + "columnType": 1, + "isNullable": true, + "dartType": "bool?" + }, + { + "name": "error", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "stackTrace", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "authenticatedUserId", + "columnType": 2, + "isNullable": true, + "dartType": "int?" + }, + { + "name": "isOpen", + "columnType": 1, + "isNullable": true, + "dartType": "bool?" + }, + { + "name": "touched", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_session_log_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_session_log_serverid_idx", + "elements": [ + { + "type": 0, + "definition": "serverId" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + }, + { + "indexName": "serverpod_session_log_touched_idx", + "elements": [ + { + "type": 0, + "definition": "touched" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + }, + { + "indexName": "serverpod_session_log_isopen_idx", + "elements": [ + { + "type": 0, + "definition": "isOpen" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + } + ], + "installedModules": [ + { + "module": "bluevsred", + "version": "20240412092530655" + }, + { + "module": "serverpod", + "version": "20240115074235544" + } + ], + "migrationApiVersion": 1 +} \ No newline at end of file diff --git a/bluevsred_server/migrations/20240412092530655/definition.sql b/bluevsred_server/migrations/20240412092530655/definition.sql new file mode 100644 index 0000000..98e1d25 --- /dev/null +++ b/bluevsred_server/migrations/20240412092530655/definition.sql @@ -0,0 +1,316 @@ +BEGIN; + +-- +-- Class BattleDb as table battle +-- +CREATE TABLE "battle" ( + "id" serial PRIMARY KEY, + "creationDate" timestamp without time zone NOT NULL, + "startDate" timestamp without time zone NOT NULL, + "maxActionPoints" double precision NOT NULL, + "actionPointsRecoveryRate" double precision NOT NULL +); + +-- +-- Class GamePlayerDb as table player +-- +CREATE TABLE "player" ( + "id" serial PRIMARY KEY, + "name" text NOT NULL +); + +-- +-- Class BattleMapDb as table talle_map +-- +CREATE TABLE "talle_map" ( + "id" serial PRIMARY KEY, + "path" text NOT NULL +); + +-- +-- Class TeamDb as table team +-- +CREATE TABLE "team" ( + "id" serial PRIMARY KEY, + "name" text NOT NULL, + "colorCode" text NOT NULL +); + +-- +-- Class TroopDb as table troop +-- +CREATE TABLE "troop" ( + "id" serial PRIMARY KEY, + "path" text NOT NULL, + "troopType" text NOT NULL +); + +-- +-- Class AuthKey as table serverpod_auth_key +-- +CREATE TABLE "serverpod_auth_key" ( + "id" serial PRIMARY KEY, + "userId" integer NOT NULL, + "hash" text NOT NULL, + "scopeNames" json NOT NULL, + "method" text NOT NULL +); + +-- Indexes +CREATE INDEX "serverpod_auth_key_userId_idx" ON "serverpod_auth_key" USING btree ("userId"); + +-- +-- Class CloudStorageEntry as table serverpod_cloud_storage +-- +CREATE TABLE "serverpod_cloud_storage" ( + "id" serial PRIMARY KEY, + "storageId" text NOT NULL, + "path" text NOT NULL, + "addedTime" timestamp without time zone NOT NULL, + "expiration" timestamp without time zone, + "byteData" bytea NOT NULL, + "verified" boolean NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_cloud_storage_path_idx" ON "serverpod_cloud_storage" USING btree ("storageId", "path"); +CREATE INDEX "serverpod_cloud_storage_expiration" ON "serverpod_cloud_storage" USING btree ("expiration"); + +-- +-- Class CloudStorageDirectUploadEntry as table serverpod_cloud_storage_direct_upload +-- +CREATE TABLE "serverpod_cloud_storage_direct_upload" ( + "id" serial PRIMARY KEY, + "storageId" text NOT NULL, + "path" text NOT NULL, + "expiration" timestamp without time zone NOT NULL, + "authKey" text NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_cloud_storage_direct_upload_storage_path" ON "serverpod_cloud_storage_direct_upload" USING btree ("storageId", "path"); + +-- +-- Class FutureCallEntry as table serverpod_future_call +-- +CREATE TABLE "serverpod_future_call" ( + "id" serial PRIMARY KEY, + "name" text NOT NULL, + "time" timestamp without time zone NOT NULL, + "serializedObject" text, + "serverId" text NOT NULL, + "identifier" text +); + +-- Indexes +CREATE INDEX "serverpod_future_call_time_idx" ON "serverpod_future_call" USING btree ("time"); +CREATE INDEX "serverpod_future_call_serverId_idx" ON "serverpod_future_call" USING btree ("serverId"); +CREATE INDEX "serverpod_future_call_identifier_idx" ON "serverpod_future_call" USING btree ("identifier"); + +-- +-- Class ServerHealthConnectionInfo as table serverpod_health_connection_info +-- +CREATE TABLE "serverpod_health_connection_info" ( + "id" serial PRIMARY KEY, + "serverId" text NOT NULL, + "timestamp" timestamp without time zone NOT NULL, + "active" integer NOT NULL, + "closing" integer NOT NULL, + "idle" integer NOT NULL, + "granularity" integer NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_health_connection_info_timestamp_idx" ON "serverpod_health_connection_info" USING btree ("timestamp", "serverId", "granularity"); + +-- +-- Class ServerHealthMetric as table serverpod_health_metric +-- +CREATE TABLE "serverpod_health_metric" ( + "id" serial PRIMARY KEY, + "name" text NOT NULL, + "serverId" text NOT NULL, + "timestamp" timestamp without time zone NOT NULL, + "isHealthy" boolean NOT NULL, + "value" double precision NOT NULL, + "granularity" integer NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_health_metric_timestamp_idx" ON "serverpod_health_metric" USING btree ("timestamp", "serverId", "name", "granularity"); + +-- +-- Class LogEntry as table serverpod_log +-- +CREATE TABLE "serverpod_log" ( + "id" serial PRIMARY KEY, + "sessionLogId" integer NOT NULL, + "messageId" integer, + "reference" text, + "serverId" text NOT NULL, + "time" timestamp without time zone NOT NULL, + "logLevel" integer NOT NULL, + "message" text NOT NULL, + "error" text, + "stackTrace" text, + "order" integer NOT NULL +); + +-- Indexes +CREATE INDEX "serverpod_log_sessionLogId_idx" ON "serverpod_log" USING btree ("sessionLogId"); + +-- +-- Class MessageLogEntry as table serverpod_message_log +-- +CREATE TABLE "serverpod_message_log" ( + "id" serial PRIMARY KEY, + "sessionLogId" integer NOT NULL, + "serverId" text NOT NULL, + "messageId" integer NOT NULL, + "endpoint" text NOT NULL, + "messageName" text NOT NULL, + "duration" double precision NOT NULL, + "error" text, + "stackTrace" text, + "slow" boolean NOT NULL, + "order" integer NOT NULL +); + +-- +-- Class MethodInfo as table serverpod_method +-- +CREATE TABLE "serverpod_method" ( + "id" serial PRIMARY KEY, + "endpoint" text NOT NULL, + "method" text NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_method_endpoint_method_idx" ON "serverpod_method" USING btree ("endpoint", "method"); + +-- +-- Class DatabaseMigrationVersion as table serverpod_migrations +-- +CREATE TABLE "serverpod_migrations" ( + "id" serial PRIMARY KEY, + "module" text NOT NULL, + "version" text NOT NULL, + "timestamp" timestamp without time zone +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_migrations_ids" ON "serverpod_migrations" USING btree ("module"); + +-- +-- Class QueryLogEntry as table serverpod_query_log +-- +CREATE TABLE "serverpod_query_log" ( + "id" serial PRIMARY KEY, + "serverId" text NOT NULL, + "sessionLogId" integer NOT NULL, + "messageId" integer, + "query" text NOT NULL, + "duration" double precision NOT NULL, + "numRows" integer, + "error" text, + "stackTrace" text, + "slow" boolean NOT NULL, + "order" integer NOT NULL +); + +-- Indexes +CREATE INDEX "serverpod_query_log_sessionLogId_idx" ON "serverpod_query_log" USING btree ("sessionLogId"); + +-- +-- Class ReadWriteTestEntry as table serverpod_readwrite_test +-- +CREATE TABLE "serverpod_readwrite_test" ( + "id" serial PRIMARY KEY, + "number" integer NOT NULL +); + +-- +-- Class RuntimeSettings as table serverpod_runtime_settings +-- +CREATE TABLE "serverpod_runtime_settings" ( + "id" serial PRIMARY KEY, + "logSettings" json NOT NULL, + "logSettingsOverrides" json NOT NULL, + "logServiceCalls" boolean NOT NULL, + "logMalformedCalls" boolean NOT NULL +); + +-- +-- Class SessionLogEntry as table serverpod_session_log +-- +CREATE TABLE "serverpod_session_log" ( + "id" serial PRIMARY KEY, + "serverId" text NOT NULL, + "time" timestamp without time zone NOT NULL, + "module" text, + "endpoint" text, + "method" text, + "duration" double precision, + "numQueries" integer, + "slow" boolean, + "error" text, + "stackTrace" text, + "authenticatedUserId" integer, + "isOpen" boolean, + "touched" timestamp without time zone NOT NULL +); + +-- Indexes +CREATE INDEX "serverpod_session_log_serverid_idx" ON "serverpod_session_log" USING btree ("serverId"); +CREATE INDEX "serverpod_session_log_touched_idx" ON "serverpod_session_log" USING btree ("touched"); +CREATE INDEX "serverpod_session_log_isopen_idx" ON "serverpod_session_log" USING btree ("isOpen"); + +-- +-- Foreign relations for "serverpod_log" table +-- +ALTER TABLE ONLY "serverpod_log" + ADD CONSTRAINT "serverpod_log_fk_0" + FOREIGN KEY("sessionLogId") + REFERENCES "serverpod_session_log"("id") + ON DELETE CASCADE + ON UPDATE NO ACTION; + +-- +-- Foreign relations for "serverpod_message_log" table +-- +ALTER TABLE ONLY "serverpod_message_log" + ADD CONSTRAINT "serverpod_message_log_fk_0" + FOREIGN KEY("sessionLogId") + REFERENCES "serverpod_session_log"("id") + ON DELETE CASCADE + ON UPDATE NO ACTION; + +-- +-- Foreign relations for "serverpod_query_log" table +-- +ALTER TABLE ONLY "serverpod_query_log" + ADD CONSTRAINT "serverpod_query_log_fk_0" + FOREIGN KEY("sessionLogId") + REFERENCES "serverpod_session_log"("id") + ON DELETE CASCADE + ON UPDATE NO ACTION; + + +-- +-- MIGRATION VERSION FOR bluevsred +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('bluevsred', '20240412092530655', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240412092530655', "timestamp" = now(); + +-- +-- MIGRATION VERSION FOR serverpod +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('serverpod', '20240115074235544', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240115074235544', "timestamp" = now(); + + +COMMIT; diff --git a/bluevsred_server/migrations/20240412092530655/definition_project.json b/bluevsred_server/migrations/20240412092530655/definition_project.json new file mode 100644 index 0000000..7c68241 --- /dev/null +++ b/bluevsred_server/migrations/20240412092530655/definition_project.json @@ -0,0 +1,231 @@ +{ + "moduleName": "bluevsred", + "tables": [ + { + "name": "battle", + "dartName": "BattleDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('battle_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "creationDate", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "startDate", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "maxActionPoints", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "actionPointsRecoveryRate", + "columnType": 3, + "isNullable": false, + "dartType": "double" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "battle_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "player", + "dartName": "GamePlayerDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('player_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "player_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "talle_map", + "dartName": "BattleMapDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('talle_map_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "talle_map_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "team", + "dartName": "TeamDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('team_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "name", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "colorCode", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "team_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "troop", + "dartName": "TroopDb", + "module": "bluevsred", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 2, + "isNullable": false, + "columnDefault": "nextval('troop_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "path", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "troopType", + "columnType": 0, + "isNullable": false, + "dartType": "protocol:TroopType" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "troop_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + } + ], + "installedModules": [ + { + "module": "serverpod", + "version": "20240115074235544" + }, + { + "module": "bluevsred", + "version": "20240412073903562" + } + ], + "migrationApiVersion": 1 +} \ No newline at end of file diff --git a/bluevsred_server/migrations/20240412092530655/migration.json b/bluevsred_server/migrations/20240412092530655/migration.json new file mode 100644 index 0000000..056118b --- /dev/null +++ b/bluevsred_server/migrations/20240412092530655/migration.json @@ -0,0 +1,5 @@ +{ + "actions": [], + "warnings": [], + "migrationApiVersion": 1 +} \ No newline at end of file diff --git a/bluevsred_server/migrations/20240412092530655/migration.sql b/bluevsred_server/migrations/20240412092530655/migration.sql new file mode 100644 index 0000000..6711518 --- /dev/null +++ b/bluevsred_server/migrations/20240412092530655/migration.sql @@ -0,0 +1,21 @@ +BEGIN; + + +-- +-- MIGRATION VERSION FOR bluevsred +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('bluevsred', '20240412092530655', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240412092530655', "timestamp" = now(); + +-- +-- MIGRATION VERSION FOR serverpod +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('serverpod', '20240115074235544', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240115074235544', "timestamp" = now(); + + +COMMIT; diff --git a/bluevsred_server/migrations/migration_registry.txt b/bluevsred_server/migrations/migration_registry.txt index 403e90a..0280547 100644 --- a/bluevsred_server/migrations/migration_registry.txt +++ b/bluevsred_server/migrations/migration_registry.txt @@ -6,3 +6,5 @@ 20240328151045625 20240403080154821 +20240412073903562 +20240412092530655 diff --git a/bluevsred_server/pubspec.yaml b/bluevsred_server/pubspec.yaml index 7915500..40e62ac 100644 --- a/bluevsred_server/pubspec.yaml +++ b/bluevsred_server/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: serverpod: 1.2.6 bluevsred_shared: path: ../bluevsred_shared - serverpod_serialization: ^1.2.6 + serverpod_serialization: 1.2.6 dev_dependencies: lints: ^3.0.0 diff --git a/bluevsred_server/repair-migration/20240412074114893.sql b/bluevsred_server/repair-migration/20240412074114893.sql new file mode 100644 index 0000000..c7283fe --- /dev/null +++ b/bluevsred_server/repair-migration/20240412074114893.sql @@ -0,0 +1,29 @@ +BEGIN; + + +-- +-- MIGRATION VERSION FOR bluevsred +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('bluevsred', '20240412073903562', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240412073903562', "timestamp" = now(); + +-- +-- MIGRATION VERSION FOR serverpod +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('serverpod', '20240115074235544', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240115074235544', "timestamp" = now(); + +-- +-- MIGRATION VERSION FOR _repair +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('_repair', '20240412074114893', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240412074114893', "timestamp" = now(); + + +COMMIT; diff --git a/bluevsred_shared/build/unit_test_assets/NOTICES.Z b/bluevsred_shared/build/unit_test_assets/NOTICES.Z index 977bff5..6c4eb2c 100644 Binary files a/bluevsred_shared/build/unit_test_assets/NOTICES.Z and b/bluevsred_shared/build/unit_test_assets/NOTICES.Z differ diff --git a/bluevsred_shared/lib/bluesvsred_shared.dart b/bluevsred_shared/lib/bluesvsred_shared.dart index 1cb5b6b..df537d4 100644 --- a/bluevsred_shared/lib/bluesvsred_shared.dart +++ b/bluevsred_shared/lib/bluesvsred_shared.dart @@ -3,3 +3,4 @@ export 'src/battle_map/battle_map.dart'; export 'src/game_player/game_player.dart'; export 'src/team/team.dart'; export 'src/troops/troop.dart'; +export 'src/troops/game_player_troops.dart'; diff --git a/bluevsred_shared/lib/src/battle/battle.dart b/bluevsred_shared/lib/src/battle/battle.dart index 75d3076..118337b 100644 --- a/bluevsred_shared/lib/src/battle/battle.dart +++ b/bluevsred_shared/lib/src/battle/battle.dart @@ -5,7 +5,6 @@ import '../troops/troop.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'battle.freezed.dart'; -part 'battle.g.dart'; @Freezed(makeCollectionsUnmodifiable: false) class Battle with _$Battle { @@ -38,10 +37,6 @@ class Battle with _$Battle { return DateTime.now().toUtc(); } - factory Battle.fromJson( - Map json, - ) => - _$BattleFromJson(json); void addTroops({required List newTroops}) { troops!.addAll(newTroops); diff --git a/bluevsred_shared/lib/src/battle/battle.freezed.dart b/bluevsred_shared/lib/src/battle/battle.freezed.dart index 3558b5e..42814a6 100644 --- a/bluevsred_shared/lib/src/battle/battle.freezed.dart +++ b/bluevsred_shared/lib/src/battle/battle.freezed.dart @@ -14,10 +14,6 @@ T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); -Battle _$BattleFromJson(Map json) { - return _Battle.fromJson(json); -} - /// @nodoc mixin _$Battle { DateTime get creationDate => throw _privateConstructorUsedError; @@ -83,7 +79,7 @@ mixin _$Battle { required TResult orElse(), }) => throw _privateConstructorUsedError; - Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) $BattleCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -240,7 +236,7 @@ class __$$BattleImplCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + class _$BattleImpl extends _Battle { _$BattleImpl( {required this.creationDate, @@ -252,9 +248,6 @@ class _$BattleImpl extends _Battle { this.teams}) : super._(); - factory _$BattleImpl.fromJson(Map json) => - _$$BattleImplFromJson(json); - @override final DateTime creationDate; @override @@ -295,7 +288,6 @@ class _$BattleImpl extends _Battle { const DeepCollectionEquality().equals(other.teams, teams)); } - @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -395,13 +387,6 @@ class _$BattleImpl extends _Battle { } return orElse(); } - - @override - Map toJson() { - return _$$BattleImplToJson( - this, - ); - } } abstract class _Battle extends Battle { @@ -415,8 +400,6 @@ abstract class _Battle extends Battle { final Set? teams}) = _$BattleImpl; _Battle._() : super._(); - factory _Battle.fromJson(Map json) = _$BattleImpl.fromJson; - @override DateTime get creationDate; @override diff --git a/bluevsred_shared/lib/src/battle/battle.g.dart b/bluevsred_shared/lib/src/battle/battle.g.dart deleted file mode 100644 index 49fa773..0000000 --- a/bluevsred_shared/lib/src/battle/battle.g.dart +++ /dev/null @@ -1,33 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'battle.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$BattleImpl _$$BattleImplFromJson(Map json) => _$BattleImpl( - creationDate: DateTime.parse(json['creationDate'] as String), - battleMap: BattleMap.fromJson(json['battleMap'] as Map), - startDate: DateTime.parse(json['startDate'] as String), - maxActionPoints: (json['maxActionPoints'] as num).toDouble(), - actionPointsRecoveryRate: - (json['actionPointsRecoveryRate'] as num).toDouble(), - troops: (json['troops'] as List?) - ?.map((e) => Troop.fromJson(e as Map)) - .toSet(), - teams: (json['teams'] as List?) - ?.map((e) => Team.fromJson(e as Map)) - .toSet(), - ); - -Map _$$BattleImplToJson(_$BattleImpl instance) => - { - 'creationDate': instance.creationDate.toIso8601String(), - 'battleMap': instance.battleMap, - 'startDate': instance.startDate.toIso8601String(), - 'maxActionPoints': instance.maxActionPoints, - 'actionPointsRecoveryRate': instance.actionPointsRecoveryRate, - 'troops': instance.troops?.toList(), - 'teams': instance.teams?.toList(), - }; diff --git a/bluevsred_shared/lib/src/troops/game_player_troops.dart b/bluevsred_shared/lib/src/troops/game_player_troops.dart new file mode 100644 index 0000000..7468eaf --- /dev/null +++ b/bluevsred_shared/lib/src/troops/game_player_troops.dart @@ -0,0 +1,12 @@ +import 'package:bluevsred_shared/bluesvsred_shared.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'game_player_troops.freezed.dart'; + +@freezed +class GamePlayerTroops with _$GamePlayerTroops { + GamePlayerTroops._(); + factory GamePlayerTroops({required Set troops}) = _GamePlayerTroops; + + +} diff --git a/bluevsred_shared/lib/src/troops/game_player_troops.freezed.dart b/bluevsred_shared/lib/src/troops/game_player_troops.freezed.dart new file mode 100644 index 0000000..2078e23 --- /dev/null +++ b/bluevsred_shared/lib/src/troops/game_player_troops.freezed.dart @@ -0,0 +1,143 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'game_player_troops.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$GamePlayerTroops { + Set get troops => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $GamePlayerTroopsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $GamePlayerTroopsCopyWith<$Res> { + factory $GamePlayerTroopsCopyWith( + GamePlayerTroops value, $Res Function(GamePlayerTroops) then) = + _$GamePlayerTroopsCopyWithImpl<$Res, GamePlayerTroops>; + @useResult + $Res call({Set troops}); +} + +/// @nodoc +class _$GamePlayerTroopsCopyWithImpl<$Res, $Val extends GamePlayerTroops> + implements $GamePlayerTroopsCopyWith<$Res> { + _$GamePlayerTroopsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? troops = null, + }) { + return _then(_value.copyWith( + troops: null == troops + ? _value.troops + : troops // ignore: cast_nullable_to_non_nullable + as Set, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$GamePlayerTroopsImplCopyWith<$Res> + implements $GamePlayerTroopsCopyWith<$Res> { + factory _$$GamePlayerTroopsImplCopyWith(_$GamePlayerTroopsImpl value, + $Res Function(_$GamePlayerTroopsImpl) then) = + __$$GamePlayerTroopsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({Set troops}); +} + +/// @nodoc +class __$$GamePlayerTroopsImplCopyWithImpl<$Res> + extends _$GamePlayerTroopsCopyWithImpl<$Res, _$GamePlayerTroopsImpl> + implements _$$GamePlayerTroopsImplCopyWith<$Res> { + __$$GamePlayerTroopsImplCopyWithImpl(_$GamePlayerTroopsImpl _value, + $Res Function(_$GamePlayerTroopsImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? troops = null, + }) { + return _then(_$GamePlayerTroopsImpl( + troops: null == troops + ? _value._troops + : troops // ignore: cast_nullable_to_non_nullable + as Set, + )); + } +} + +/// @nodoc + +class _$GamePlayerTroopsImpl extends _GamePlayerTroops { + _$GamePlayerTroopsImpl({required final Set troops}) + : _troops = troops, + super._(); + + final Set _troops; + @override + Set get troops { + if (_troops is EqualUnmodifiableSetView) return _troops; + // ignore: implicit_dynamic_type + return EqualUnmodifiableSetView(_troops); + } + + @override + String toString() { + return 'GamePlayerTroops(troops: $troops)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$GamePlayerTroopsImpl && + const DeepCollectionEquality().equals(other._troops, _troops)); + } + + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(_troops)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$GamePlayerTroopsImplCopyWith<_$GamePlayerTroopsImpl> get copyWith => + __$$GamePlayerTroopsImplCopyWithImpl<_$GamePlayerTroopsImpl>( + this, _$identity); +} + +abstract class _GamePlayerTroops extends GamePlayerTroops { + factory _GamePlayerTroops({required final Set troops}) = + _$GamePlayerTroopsImpl; + _GamePlayerTroops._() : super._(); + + @override + Set get troops; + @override + @JsonKey(ignore: true) + _$$GamePlayerTroopsImplCopyWith<_$GamePlayerTroopsImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/bluevsred_shared/lib/src/troops/troop.dart b/bluevsred_shared/lib/src/troops/troop.dart index ab3b208..98d1d04 100644 --- a/bluevsred_shared/lib/src/troops/troop.dart +++ b/bluevsred_shared/lib/src/troops/troop.dart @@ -1,27 +1,16 @@ -import '../game_player/game_player.dart'; +import 'package:bluevsred_client/bluevsred_client.dart'; +import 'package:bluevsred_shared/bluesvsred_shared.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:serverpod_serialization/serverpod_serialization.dart'; + +import '../game_player/game_player.dart'; part 'troop.freezed.dart'; -part 'troop.g.dart'; @freezed -abstract class Troop with _$Troop { +class Troop with _$Troop { Troop._(); - factory Troop.def( - {required String id, - required String path, - required GamePlayer gamePlayer}) = _Troop; - factory Troop({required GamePlayer gamePlayer}) => - _Troop(id: _uuid(), path: 'testing_troop.png', gamePlayer: gamePlayer); - factory Troop.fromJson(Map json, - ) => _$TroopFromJson(json); - - get actionPoints { - return 30; - } - static String _uuid() { - const generator = Uuid(); - return generator.v4(); - } + factory Troop({ + required TroopDb troopDb, + required GamePlayer gamePlayer, + }) = _Troop; } diff --git a/bluevsred_shared/lib/src/troops/troop.freezed.dart b/bluevsred_shared/lib/src/troops/troop.freezed.dart index 5007c95..a9fc4bf 100644 --- a/bluevsred_shared/lib/src/troops/troop.freezed.dart +++ b/bluevsred_shared/lib/src/troops/troop.freezed.dart @@ -14,49 +14,11 @@ T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); -Troop _$TroopFromJson(Map json) { - return _Troop.fromJson(json); -} - /// @nodoc mixin _$Troop { - String get id => throw _privateConstructorUsedError; - String get path => throw _privateConstructorUsedError; + TroopDb get troopDb => throw _privateConstructorUsedError; GamePlayer get gamePlayer => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult when({ - required TResult Function(String id, String path, GamePlayer gamePlayer) - def, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String id, String path, GamePlayer gamePlayer)? def, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String id, String path, GamePlayer gamePlayer)? def, - required TResult orElse(), - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_Troop value) def, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Troop value)? def, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Troop value)? def, - required TResult orElse(), - }) => - throw _privateConstructorUsedError; - Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) $TroopCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -66,7 +28,7 @@ abstract class $TroopCopyWith<$Res> { factory $TroopCopyWith(Troop value, $Res Function(Troop) then) = _$TroopCopyWithImpl<$Res, Troop>; @useResult - $Res call({String id, String path, GamePlayer gamePlayer}); + $Res call({TroopDb troopDb, GamePlayer gamePlayer}); $GamePlayerCopyWith<$Res> get gamePlayer; } @@ -84,19 +46,14 @@ class _$TroopCopyWithImpl<$Res, $Val extends Troop> @pragma('vm:prefer-inline') @override $Res call({ - Object? id = null, - Object? path = null, + Object? troopDb = null, Object? gamePlayer = null, }) { return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String, - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, + troopDb: null == troopDb + ? _value.troopDb + : troopDb // ignore: cast_nullable_to_non_nullable + as TroopDb, gamePlayer: null == gamePlayer ? _value.gamePlayer : gamePlayer // ignore: cast_nullable_to_non_nullable @@ -120,7 +77,7 @@ abstract class _$$TroopImplCopyWith<$Res> implements $TroopCopyWith<$Res> { __$$TroopImplCopyWithImpl<$Res>; @override @useResult - $Res call({String id, String path, GamePlayer gamePlayer}); + $Res call({TroopDb troopDb, GamePlayer gamePlayer}); @override $GamePlayerCopyWith<$Res> get gamePlayer; @@ -137,19 +94,14 @@ class __$$TroopImplCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? id = null, - Object? path = null, + Object? troopDb = null, Object? gamePlayer = null, }) { return _then(_$TroopImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String, - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, + troopDb: null == troopDb + ? _value.troopDb + : troopDb // ignore: cast_nullable_to_non_nullable + as TroopDb, gamePlayer: null == gamePlayer ? _value.gamePlayer : gamePlayer // ignore: cast_nullable_to_non_nullable @@ -159,24 +111,18 @@ class __$$TroopImplCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() -class _$TroopImpl extends _Troop { - _$TroopImpl({required this.id, required this.path, required this.gamePlayer}) - : super._(); - factory _$TroopImpl.fromJson(Map json) => - _$$TroopImplFromJson(json); +class _$TroopImpl extends _Troop { + _$TroopImpl({required this.troopDb, required this.gamePlayer}) : super._(); @override - final String id; - @override - final String path; + final TroopDb troopDb; @override final GamePlayer gamePlayer; @override String toString() { - return 'Troop.def(id: $id, path: $path, gamePlayer: $gamePlayer)'; + return 'Troop(troopDb: $troopDb, gamePlayer: $gamePlayer)'; } @override @@ -184,100 +130,29 @@ class _$TroopImpl extends _Troop { return identical(this, other) || (other.runtimeType == runtimeType && other is _$TroopImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.path, path) || other.path == path) && + (identical(other.troopDb, troopDb) || other.troopDb == troopDb) && (identical(other.gamePlayer, gamePlayer) || other.gamePlayer == gamePlayer)); } - @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, id, path, gamePlayer); + int get hashCode => Object.hash(runtimeType, troopDb, gamePlayer); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$TroopImplCopyWith<_$TroopImpl> get copyWith => __$$TroopImplCopyWithImpl<_$TroopImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String id, String path, GamePlayer gamePlayer) - def, - }) { - return def(id, path, gamePlayer); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String id, String path, GamePlayer gamePlayer)? def, - }) { - return def?.call(id, path, gamePlayer); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String id, String path, GamePlayer gamePlayer)? def, - required TResult orElse(), - }) { - if (def != null) { - return def(id, path, gamePlayer); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_Troop value) def, - }) { - return def(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Troop value)? def, - }) { - return def?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Troop value)? def, - required TResult orElse(), - }) { - if (def != null) { - return def(this); - } - return orElse(); - } - - @override - Map toJson() { - return _$$TroopImplToJson( - this, - ); - } } abstract class _Troop extends Troop { factory _Troop( - {required final String id, - required final String path, + {required final TroopDb troopDb, required final GamePlayer gamePlayer}) = _$TroopImpl; _Troop._() : super._(); - factory _Troop.fromJson(Map json) = _$TroopImpl.fromJson; - - @override - String get id; @override - String get path; + TroopDb get troopDb; @override GamePlayer get gamePlayer; @override diff --git a/bluevsred_shared/lib/src/troops/troop.g.dart b/bluevsred_shared/lib/src/troops/troop.g.dart deleted file mode 100644 index 3218636..0000000 --- a/bluevsred_shared/lib/src/troops/troop.g.dart +++ /dev/null @@ -1,21 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'troop.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$TroopImpl _$$TroopImplFromJson(Map json) => _$TroopImpl( - id: json['id'] as String, - path: json['path'] as String, - gamePlayer: - GamePlayer.fromJson(json['gamePlayer'] as Map), - ); - -Map _$$TroopImplToJson(_$TroopImpl instance) => - { - 'id': instance.id, - 'path': instance.path, - 'gamePlayer': instance.gamePlayer, - }; diff --git a/bluevsred_shared/pubspec.yaml b/bluevsred_shared/pubspec.yaml index 8e4013f..5be6cfe 100644 --- a/bluevsred_shared/pubspec.yaml +++ b/bluevsred_shared/pubspec.yaml @@ -8,11 +8,13 @@ environment: # Add regular dependencies here. dependencies: - serverpod_serialization: ^1.2.6 + serverpod_serialization: 1.2.6 freezed_annotation: ^2.4.1 json_annotation: ^4.8.1 # path: ^1.8.0 uuid: ^4.3.3 + bluevsred_client: + path: ../bluevsred_client dev_dependencies: diff --git a/bluevsred_shared/test/action_points_lifecycle_test.dart b/bluevsred_shared/test/action_points_lifecycle_test.dart index 610e7fc..529444f 100644 --- a/bluevsred_shared/test/action_points_lifecycle_test.dart +++ b/bluevsred_shared/test/action_points_lifecycle_test.dart @@ -1,3 +1,4 @@ +import 'package:bluevsred_client/bluevsred_client.dart'; import 'package:bluevsred_shared/src/battle/battle.dart'; import 'package:bluevsred_shared/src/game_player/game_player.dart'; import 'package:bluevsred_shared/src/troops/troop.dart'; @@ -9,7 +10,7 @@ void main() { maxActionPoints: 30, actionPointsRecoveryRate: 1); final initialGamePlayer1 = GamePlayer(name: 'test player name'); - final initialTroop1 = Troop(gamePlayer: initialGamePlayer1); + final initialTroop1 = Troop(gamePlayer: initialGamePlayer1, troopDb: TroopDb(troopType: TroopType.commander, actionPoints: 10)); group('Action Points lifecycle', () { test( @@ -23,7 +24,7 @@ void main() { var isTestTroopFound = false; for (final battleTroop in battle.troops!) { if (battleTroop == testTroop) { - expect(battleTroop.actionPoints, equals(maxActionPoints)); + expect(battleTroop.troopDb.actionPoints, equals(maxActionPoints)); isTestTroopFound = true; return; } diff --git a/bluevsred_shared/test/game_global_description_test.dart b/bluevsred_shared/test/game_global_description_test.dart index b86ee32..32cb3ee 100644 --- a/bluevsred_shared/test/game_global_description_test.dart +++ b/bluevsred_shared/test/game_global_description_test.dart @@ -1,3 +1,4 @@ +import 'package:bluevsred_client/bluevsred_client.dart'; import 'package:bluevsred_shared/src/battle/battle.dart'; import 'package:bluevsred_shared/src/game_player/game_player.dart'; import 'package:bluevsred_shared/src/team/team.dart'; @@ -13,7 +14,9 @@ void main() { () { test('Troop added to a battle is in the list of troops', () { final gamePlayer = GamePlayer(name: 'test player name'); - final troop = Troop(gamePlayer: gamePlayer); + final troop = Troop( + gamePlayer: gamePlayer, + troopDb: TroopDb(troopType: TroopType.commander, actionPoints: 10)); final battle = Battle( startDate: DateTime.now().toUtc().add(const Duration(minutes: 1)), maxActionPoints: 30, @@ -23,7 +26,9 @@ void main() { }); test('Troop is added only once to a battle (already added)', () { final gamePlayer = GamePlayer(name: 'test player name'); - final troop = Troop(gamePlayer: gamePlayer); + final troop = Troop( + gamePlayer: gamePlayer, + troopDb: TroopDb(troopType: TroopType.commander, actionPoints: 10)); final battle = Battle( startDate: DateTime.now().toUtc().add(const Duration(minutes: 1)), maxActionPoints: 30, @@ -38,7 +43,7 @@ void main() { 'Troop is added only once to a battle (attempt to add same troop twice in the same list)', () { final gamePlayer = GamePlayer(name: 'test player name'); - final troop = Troop(gamePlayer: gamePlayer); + final troop = Troop(gamePlayer: gamePlayer, troopDb: TroopDb(troopType: TroopType.commander, actionPoints: 10)); final battle = Battle( startDate: DateTime.now().toUtc().add(const Duration(minutes: 1)), maxActionPoints: 30,