diff --git a/wien_talks/wien_talks_client/lib/src/protocol/client.dart b/wien_talks/wien_talks_client/lib/src/protocol/client.dart index eed83e0..dcae10e 100644 --- a/wien_talks/wien_talks_client/lib/src/protocol/client.dart +++ b/wien_talks/wien_talks_client/lib/src/protocol/client.dart @@ -19,29 +19,29 @@ import 'package:serverpod_auth_client/serverpod_auth_client.dart' as _i7; import 'protocol.dart' as _i8; /// {@category Endpoint} -class EndpointShowLatestNewsWidget extends _i1.EndpointRef { - EndpointShowLatestNewsWidget(_i1.EndpointCaller caller) : super(caller); +class EndpointQuote extends _i1.EndpointRef { + EndpointQuote(_i1.EndpointCaller caller) : super(caller); @override - String get name => 'showLatestNewsWidget'; + String get name => 'quote'; _i2.Future<_i3.Quote> createQuote(_i4.CreateQuoteRequest req) => caller.callServerEndpoint<_i3.Quote>( - 'showLatestNewsWidget', + 'quote', 'createQuote', {'req': req}, ); _i2.Future updateQuote(_i3.Quote quote) => caller.callServerEndpoint( - 'showLatestNewsWidget', + 'quote', 'updateQuote', {'quote': quote}, ); _i2.Future> getAllQuotes() => caller.callServerEndpoint>( - 'showLatestNewsWidget', + 'quote', 'getAllQuotes', {}, ); @@ -103,19 +103,22 @@ class Client extends _i1.ServerpodClientShared { disconnectStreamsOnLostInternetConnection: disconnectStreamsOnLostInternetConnection, ) { - showLatestNewsWidget = EndpointShowLatestNewsWidget(this); + quote = EndpointQuote(this); + votes = EndpointVotes(this); modules = Modules(this); } - late final EndpointShowLatestNewsWidget showLatestNewsWidget; + late final EndpointQuote quote; late final EndpointVotes votes; late final Modules modules; @override - Map get endpointRefLookup => - {'showLatestNewsWidget': showLatestNewsWidget}; + Map get endpointRefLookup => { + 'quote': quote, + 'votes': votes, + }; @override Map get moduleLookup => diff --git a/wien_talks/wien_talks_client/lib/src/protocol/votes/vote.dart b/wien_talks/wien_talks_client/lib/src/protocol/votes/vote.dart new file mode 100644 index 0000000..5e969f1 --- /dev/null +++ b/wien_talks/wien_talks_client/lib/src/protocol/votes/vote.dart @@ -0,0 +1,120 @@ +/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ +/* To generate run: "serverpod generate" */ + +// ignore_for_file: implementation_imports +// ignore_for_file: library_private_types_in_public_api +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: public_member_api_docs +// ignore_for_file: type_literal_in_constant_pattern +// ignore_for_file: use_super_parameters + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:serverpod_client/serverpod_client.dart' as _i1; +import '../quotes/quote.dart' as _i2; + +abstract class Vote implements _i1.SerializableModel { + Vote._({ + this.id, + required this.userId, + required this.createdAt, + required this.quote, + required this.upvote, + }); + + factory Vote({ + int? id, + required int userId, + required DateTime createdAt, + required _i2.Quote quote, + required bool upvote, + }) = _VoteImpl; + + factory Vote.fromJson(Map jsonSerialization) { + return Vote( + id: jsonSerialization['id'] as int?, + userId: jsonSerialization['userId'] as int, + createdAt: + _i1.DateTimeJsonExtension.fromJson(jsonSerialization['createdAt']), + quote: _i2.Quote.fromJson( + (jsonSerialization['quote'] as Map)), + upvote: jsonSerialization['upvote'] as bool, + ); + } + + /// The database id, set if the object has been inserted into the + /// database or if it has been fetched from the database. Otherwise, + /// the id will be null. + int? id; + + int userId; + + DateTime createdAt; + + _i2.Quote quote; + + bool upvote; + + /// Returns a shallow copy of this [Vote] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + Vote copyWith({ + int? id, + int? userId, + DateTime? createdAt, + _i2.Quote? quote, + bool? upvote, + }); + @override + Map toJson() { + return { + if (id != null) 'id': id, + 'userId': userId, + 'createdAt': createdAt.toJson(), + 'quote': quote.toJson(), + 'upvote': upvote, + }; + } + + @override + String toString() { + return _i1.SerializationManager.encode(this); + } +} + +class _Undefined {} + +class _VoteImpl extends Vote { + _VoteImpl({ + int? id, + required int userId, + required DateTime createdAt, + required _i2.Quote quote, + required bool upvote, + }) : super._( + id: id, + userId: userId, + createdAt: createdAt, + quote: quote, + upvote: upvote, + ); + + /// Returns a shallow copy of this [Vote] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + @override + Vote copyWith({ + Object? id = _Undefined, + int? userId, + DateTime? createdAt, + _i2.Quote? quote, + bool? upvote, + }) { + return Vote( + id: id is int? ? id : this.id, + userId: userId ?? this.userId, + createdAt: createdAt ?? this.createdAt, + quote: quote ?? this.quote.copyWith(), + upvote: upvote ?? this.upvote, + ); + } +} diff --git a/wien_talks/wien_talks_client/lib/src/protocol/votes/vote_request.dart b/wien_talks/wien_talks_client/lib/src/protocol/votes/vote_request.dart new file mode 100644 index 0000000..baf48e9 --- /dev/null +++ b/wien_talks/wien_talks_client/lib/src/protocol/votes/vote_request.dart @@ -0,0 +1,108 @@ +/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ +/* To generate run: "serverpod generate" */ + +// ignore_for_file: implementation_imports +// ignore_for_file: library_private_types_in_public_api +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: public_member_api_docs +// ignore_for_file: type_literal_in_constant_pattern +// ignore_for_file: use_super_parameters + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:serverpod_client/serverpod_client.dart' as _i1; +import '../quotes/quote.dart' as _i2; + +abstract class VoteRequest implements _i1.SerializableModel { + VoteRequest._({ + this.id, + required this.userId, + required this.quote, + required this.upvote, + }); + + factory VoteRequest({ + int? id, + required int userId, + required _i2.Quote quote, + required bool upvote, + }) = _VoteRequestImpl; + + factory VoteRequest.fromJson(Map jsonSerialization) { + return VoteRequest( + id: jsonSerialization['id'] as int?, + userId: jsonSerialization['userId'] as int, + quote: _i2.Quote.fromJson( + (jsonSerialization['quote'] as Map)), + upvote: jsonSerialization['upvote'] as bool, + ); + } + + /// The database id, set if the object has been inserted into the + /// database or if it has been fetched from the database. Otherwise, + /// the id will be null. + int? id; + + int userId; + + _i2.Quote quote; + + bool upvote; + + /// Returns a shallow copy of this [VoteRequest] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + VoteRequest copyWith({ + int? id, + int? userId, + _i2.Quote? quote, + bool? upvote, + }); + @override + Map toJson() { + return { + if (id != null) 'id': id, + 'userId': userId, + 'quote': quote.toJson(), + 'upvote': upvote, + }; + } + + @override + String toString() { + return _i1.SerializationManager.encode(this); + } +} + +class _Undefined {} + +class _VoteRequestImpl extends VoteRequest { + _VoteRequestImpl({ + int? id, + required int userId, + required _i2.Quote quote, + required bool upvote, + }) : super._( + id: id, + userId: userId, + quote: quote, + upvote: upvote, + ); + + /// Returns a shallow copy of this [VoteRequest] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + @override + VoteRequest copyWith({ + Object? id = _Undefined, + int? userId, + _i2.Quote? quote, + bool? upvote, + }) { + return VoteRequest( + id: id is int? ? id : this.id, + userId: userId ?? this.userId, + quote: quote ?? this.quote.copyWith(), + upvote: upvote ?? this.upvote, + ); + } +} diff --git a/wien_talks/wien_talks_server/lib/src/generated/endpoints.dart b/wien_talks/wien_talks_server/lib/src/generated/endpoints.dart index 187dc65..c6cdd86 100644 --- a/wien_talks/wien_talks_server/lib/src/generated/endpoints.dart +++ b/wien_talks/wien_talks_server/lib/src/generated/endpoints.dart @@ -22,16 +22,22 @@ class Endpoints extends _i1.EndpointDispatch { @override void initializeEndpoints(_i1.Server server) { var endpoints = { - 'showLatestNewsWidget': _i2.ShowLatestNewsWidget() + 'quote': _i2.QuoteEndpoint() ..initialize( server, - 'showLatestNewsWidget', + 'quote', null, - ) + ), + 'votes': _i3.VotesEndpoint() + ..initialize( + server, + 'votes', + null, + ), }; - connectors['showLatestNewsWidget'] = _i1.EndpointConnector( - name: 'showLatestNewsWidget', - endpoint: endpoints['showLatestNewsWidget']!, + connectors['quote'] = _i1.EndpointConnector( + name: 'quote', + endpoint: endpoints['quote']!, methodConnectors: { 'createQuote': _i1.MethodConnector( name: 'createQuote', @@ -46,8 +52,7 @@ class Endpoints extends _i1.EndpointDispatch { _i1.Session session, Map params, ) async => - (endpoints['showLatestNewsWidget'] as _i2.ShowLatestNewsWidget) - .createQuote( + (endpoints['quote'] as _i2.QuoteEndpoint).createQuote( session, params['req'], ), @@ -65,8 +70,7 @@ class Endpoints extends _i1.EndpointDispatch { _i1.Session session, Map params, ) async => - (endpoints['showLatestNewsWidget'] as _i2.ShowLatestNewsWidget) - .updateQuote( + (endpoints['quote'] as _i2.QuoteEndpoint).updateQuote( session, params['quote'], ), @@ -99,8 +103,7 @@ class Endpoints extends _i1.EndpointDispatch { _i1.Session session, Map params, ) async => - (endpoints['showLatestNewsWidget'] as _i2.ShowLatestNewsWidget) - .getAllQuotes( + (endpoints['votes'] as _i3.VotesEndpoint).postVote( session, params['voteRequest'], ), diff --git a/wien_talks/wien_talks_server/lib/src/generated/votes/vote.dart b/wien_talks/wien_talks_server/lib/src/generated/votes/vote.dart new file mode 100644 index 0000000..a150695 --- /dev/null +++ b/wien_talks/wien_talks_server/lib/src/generated/votes/vote.dart @@ -0,0 +1,441 @@ +/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ +/* To generate run: "serverpod generate" */ + +// ignore_for_file: implementation_imports +// ignore_for_file: library_private_types_in_public_api +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: public_member_api_docs +// ignore_for_file: type_literal_in_constant_pattern +// ignore_for_file: use_super_parameters + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:serverpod/serverpod.dart' as _i1; +import '../quotes/quote.dart' as _i2; + +abstract class Vote implements _i1.TableRow, _i1.ProtocolSerialization { + Vote._({ + this.id, + required this.userId, + required this.createdAt, + required this.quote, + required this.upvote, + }); + + factory Vote({ + int? id, + required int userId, + required DateTime createdAt, + required _i2.Quote quote, + required bool upvote, + }) = _VoteImpl; + + factory Vote.fromJson(Map jsonSerialization) { + return Vote( + id: jsonSerialization['id'] as int?, + userId: jsonSerialization['userId'] as int, + createdAt: + _i1.DateTimeJsonExtension.fromJson(jsonSerialization['createdAt']), + quote: _i2.Quote.fromJson( + (jsonSerialization['quote'] as Map)), + upvote: jsonSerialization['upvote'] as bool, + ); + } + + static final t = VoteTable(); + + static const db = VoteRepository._(); + + @override + int? id; + + int userId; + + DateTime createdAt; + + _i2.Quote quote; + + bool upvote; + + @override + _i1.Table get table => t; + + /// Returns a shallow copy of this [Vote] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + Vote copyWith({ + int? id, + int? userId, + DateTime? createdAt, + _i2.Quote? quote, + bool? upvote, + }); + @override + Map toJson() { + return { + if (id != null) 'id': id, + 'userId': userId, + 'createdAt': createdAt.toJson(), + 'quote': quote.toJson(), + 'upvote': upvote, + }; + } + + @override + Map toJsonForProtocol() { + return { + if (id != null) 'id': id, + 'userId': userId, + 'createdAt': createdAt.toJson(), + 'quote': quote.toJsonForProtocol(), + 'upvote': upvote, + }; + } + + static VoteInclude include() { + return VoteInclude._(); + } + + static VoteIncludeList includeList({ + _i1.WhereExpressionBuilder? where, + int? limit, + int? offset, + _i1.OrderByBuilder? orderBy, + bool orderDescending = false, + _i1.OrderByListBuilder? orderByList, + VoteInclude? include, + }) { + return VoteIncludeList._( + where: where, + limit: limit, + offset: offset, + orderBy: orderBy?.call(Vote.t), + orderDescending: orderDescending, + orderByList: orderByList?.call(Vote.t), + include: include, + ); + } + + @override + String toString() { + return _i1.SerializationManager.encode(this); + } +} + +class _Undefined {} + +class _VoteImpl extends Vote { + _VoteImpl({ + int? id, + required int userId, + required DateTime createdAt, + required _i2.Quote quote, + required bool upvote, + }) : super._( + id: id, + userId: userId, + createdAt: createdAt, + quote: quote, + upvote: upvote, + ); + + /// Returns a shallow copy of this [Vote] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + @override + Vote copyWith({ + Object? id = _Undefined, + int? userId, + DateTime? createdAt, + _i2.Quote? quote, + bool? upvote, + }) { + return Vote( + id: id is int? ? id : this.id, + userId: userId ?? this.userId, + createdAt: createdAt ?? this.createdAt, + quote: quote ?? this.quote.copyWith(), + upvote: upvote ?? this.upvote, + ); + } +} + +class VoteTable extends _i1.Table { + VoteTable({super.tableRelation}) : super(tableName: 'vote') { + userId = _i1.ColumnInt( + 'userId', + this, + ); + createdAt = _i1.ColumnDateTime( + 'createdAt', + this, + ); + quote = _i1.ColumnSerializable( + 'quote', + this, + ); + upvote = _i1.ColumnBool( + 'upvote', + this, + ); + } + + late final _i1.ColumnInt userId; + + late final _i1.ColumnDateTime createdAt; + + late final _i1.ColumnSerializable quote; + + late final _i1.ColumnBool upvote; + + @override + List<_i1.Column> get columns => [ + id, + userId, + createdAt, + quote, + upvote, + ]; +} + +class VoteInclude extends _i1.IncludeObject { + VoteInclude._(); + + @override + Map get includes => {}; + + @override + _i1.Table get table => Vote.t; +} + +class VoteIncludeList extends _i1.IncludeList { + VoteIncludeList._({ + _i1.WhereExpressionBuilder? where, + super.limit, + super.offset, + super.orderBy, + super.orderDescending, + super.orderByList, + super.include, + }) { + super.where = where?.call(Vote.t); + } + + @override + Map get includes => include?.includes ?? {}; + + @override + _i1.Table get table => Vote.t; +} + +class VoteRepository { + const VoteRepository._(); + + /// Returns a list of [Vote]s matching the given query parameters. + /// + /// Use [where] to specify which items to include in the return value. + /// If none is specified, all items will be returned. + /// + /// To specify the order of the items use [orderBy] or [orderByList] + /// when sorting by multiple columns. + /// + /// The maximum number of items can be set by [limit]. If no limit is set, + /// all items matching the query will be returned. + /// + /// [offset] defines how many items to skip, after which [limit] (or all) + /// items are read from the database. + /// + /// ```dart + /// var persons = await Persons.db.find( + /// session, + /// where: (t) => t.lastName.equals('Jones'), + /// orderBy: (t) => t.firstName, + /// limit: 100, + /// ); + /// ``` + Future> find( + _i1.Session session, { + _i1.WhereExpressionBuilder? where, + int? limit, + int? offset, + _i1.OrderByBuilder? orderBy, + bool orderDescending = false, + _i1.OrderByListBuilder? orderByList, + _i1.Transaction? transaction, + }) async { + return session.db.find( + where: where?.call(Vote.t), + orderBy: orderBy?.call(Vote.t), + orderByList: orderByList?.call(Vote.t), + orderDescending: orderDescending, + limit: limit, + offset: offset, + transaction: transaction, + ); + } + + /// Returns the first matching [Vote] matching the given query parameters. + /// + /// Use [where] to specify which items to include in the return value. + /// If none is specified, all items will be returned. + /// + /// To specify the order use [orderBy] or [orderByList] + /// when sorting by multiple columns. + /// + /// [offset] defines how many items to skip, after which the next one will be picked. + /// + /// ```dart + /// var youngestPerson = await Persons.db.findFirstRow( + /// session, + /// where: (t) => t.lastName.equals('Jones'), + /// orderBy: (t) => t.age, + /// ); + /// ``` + Future findFirstRow( + _i1.Session session, { + _i1.WhereExpressionBuilder? where, + int? offset, + _i1.OrderByBuilder? orderBy, + bool orderDescending = false, + _i1.OrderByListBuilder? orderByList, + _i1.Transaction? transaction, + }) async { + return session.db.findFirstRow( + where: where?.call(Vote.t), + orderBy: orderBy?.call(Vote.t), + orderByList: orderByList?.call(Vote.t), + orderDescending: orderDescending, + offset: offset, + transaction: transaction, + ); + } + + /// Finds a single [Vote] by its [id] or null if no such row exists. + Future findById( + _i1.Session session, + int id, { + _i1.Transaction? transaction, + }) async { + return session.db.findById( + id, + transaction: transaction, + ); + } + + /// Inserts all [Vote]s in the list and returns the inserted rows. + /// + /// The returned [Vote]s will have their `id` fields set. + /// + /// This is an atomic operation, meaning that if one of the rows fails to + /// insert, none of the rows will be inserted. + Future> insert( + _i1.Session session, + List rows, { + _i1.Transaction? transaction, + }) async { + return session.db.insert( + rows, + transaction: transaction, + ); + } + + /// Inserts a single [Vote] and returns the inserted row. + /// + /// The returned [Vote] will have its `id` field set. + Future insertRow( + _i1.Session session, + Vote row, { + _i1.Transaction? transaction, + }) async { + return session.db.insertRow( + row, + transaction: transaction, + ); + } + + /// Updates all [Vote]s in the list and returns the updated rows. If + /// [columns] is provided, only those columns will be updated. Defaults to + /// all columns. + /// This is an atomic operation, meaning that if one of the rows fails to + /// update, none of the rows will be updated. + Future> update( + _i1.Session session, + List rows, { + _i1.ColumnSelections? columns, + _i1.Transaction? transaction, + }) async { + return session.db.update( + rows, + columns: columns?.call(Vote.t), + transaction: transaction, + ); + } + + /// Updates a single [Vote]. The row needs to have its id set. + /// Optionally, a list of [columns] can be provided to only update those + /// columns. Defaults to all columns. + Future updateRow( + _i1.Session session, + Vote row, { + _i1.ColumnSelections? columns, + _i1.Transaction? transaction, + }) async { + return session.db.updateRow( + row, + columns: columns?.call(Vote.t), + transaction: transaction, + ); + } + + /// Deletes all [Vote]s in the list and returns the deleted rows. + /// This is an atomic operation, meaning that if one of the rows fail to + /// be deleted, none of the rows will be deleted. + Future> delete( + _i1.Session session, + List rows, { + _i1.Transaction? transaction, + }) async { + return session.db.delete( + rows, + transaction: transaction, + ); + } + + /// Deletes a single [Vote]. + Future deleteRow( + _i1.Session session, + Vote row, { + _i1.Transaction? transaction, + }) async { + return session.db.deleteRow( + row, + transaction: transaction, + ); + } + + /// Deletes all rows matching the [where] expression. + Future> deleteWhere( + _i1.Session session, { + required _i1.WhereExpressionBuilder where, + _i1.Transaction? transaction, + }) async { + return session.db.deleteWhere( + where: where(Vote.t), + transaction: transaction, + ); + } + + /// Counts the number of rows matching the [where] expression. If omitted, + /// will return the count of all rows in the table. + Future count( + _i1.Session session, { + _i1.WhereExpressionBuilder? where, + int? limit, + _i1.Transaction? transaction, + }) async { + return session.db.count( + where: where?.call(Vote.t), + limit: limit, + transaction: transaction, + ); + } +} diff --git a/wien_talks/wien_talks_server/lib/src/generated/votes/vote_request.dart b/wien_talks/wien_talks_server/lib/src/generated/votes/vote_request.dart new file mode 100644 index 0000000..4c03e8a --- /dev/null +++ b/wien_talks/wien_talks_server/lib/src/generated/votes/vote_request.dart @@ -0,0 +1,422 @@ +/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ +/* To generate run: "serverpod generate" */ + +// ignore_for_file: implementation_imports +// ignore_for_file: library_private_types_in_public_api +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: public_member_api_docs +// ignore_for_file: type_literal_in_constant_pattern +// ignore_for_file: use_super_parameters + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:serverpod/serverpod.dart' as _i1; +import '../quotes/quote.dart' as _i2; + +abstract class VoteRequest + implements _i1.TableRow, _i1.ProtocolSerialization { + VoteRequest._({ + this.id, + required this.userId, + required this.quote, + required this.upvote, + }); + + factory VoteRequest({ + int? id, + required int userId, + required _i2.Quote quote, + required bool upvote, + }) = _VoteRequestImpl; + + factory VoteRequest.fromJson(Map jsonSerialization) { + return VoteRequest( + id: jsonSerialization['id'] as int?, + userId: jsonSerialization['userId'] as int, + quote: _i2.Quote.fromJson( + (jsonSerialization['quote'] as Map)), + upvote: jsonSerialization['upvote'] as bool, + ); + } + + static final t = VoteRequestTable(); + + static const db = VoteRequestRepository._(); + + @override + int? id; + + int userId; + + _i2.Quote quote; + + bool upvote; + + @override + _i1.Table get table => t; + + /// Returns a shallow copy of this [VoteRequest] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + VoteRequest copyWith({ + int? id, + int? userId, + _i2.Quote? quote, + bool? upvote, + }); + @override + Map toJson() { + return { + if (id != null) 'id': id, + 'userId': userId, + 'quote': quote.toJson(), + 'upvote': upvote, + }; + } + + @override + Map toJsonForProtocol() { + return { + if (id != null) 'id': id, + 'userId': userId, + 'quote': quote.toJsonForProtocol(), + 'upvote': upvote, + }; + } + + static VoteRequestInclude include() { + return VoteRequestInclude._(); + } + + static VoteRequestIncludeList includeList({ + _i1.WhereExpressionBuilder? where, + int? limit, + int? offset, + _i1.OrderByBuilder? orderBy, + bool orderDescending = false, + _i1.OrderByListBuilder? orderByList, + VoteRequestInclude? include, + }) { + return VoteRequestIncludeList._( + where: where, + limit: limit, + offset: offset, + orderBy: orderBy?.call(VoteRequest.t), + orderDescending: orderDescending, + orderByList: orderByList?.call(VoteRequest.t), + include: include, + ); + } + + @override + String toString() { + return _i1.SerializationManager.encode(this); + } +} + +class _Undefined {} + +class _VoteRequestImpl extends VoteRequest { + _VoteRequestImpl({ + int? id, + required int userId, + required _i2.Quote quote, + required bool upvote, + }) : super._( + id: id, + userId: userId, + quote: quote, + upvote: upvote, + ); + + /// Returns a shallow copy of this [VoteRequest] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + @override + VoteRequest copyWith({ + Object? id = _Undefined, + int? userId, + _i2.Quote? quote, + bool? upvote, + }) { + return VoteRequest( + id: id is int? ? id : this.id, + userId: userId ?? this.userId, + quote: quote ?? this.quote.copyWith(), + upvote: upvote ?? this.upvote, + ); + } +} + +class VoteRequestTable extends _i1.Table { + VoteRequestTable({super.tableRelation}) : super(tableName: 'vote_request') { + userId = _i1.ColumnInt( + 'userId', + this, + ); + quote = _i1.ColumnSerializable( + 'quote', + this, + ); + upvote = _i1.ColumnBool( + 'upvote', + this, + ); + } + + late final _i1.ColumnInt userId; + + late final _i1.ColumnSerializable quote; + + late final _i1.ColumnBool upvote; + + @override + List<_i1.Column> get columns => [ + id, + userId, + quote, + upvote, + ]; +} + +class VoteRequestInclude extends _i1.IncludeObject { + VoteRequestInclude._(); + + @override + Map get includes => {}; + + @override + _i1.Table get table => VoteRequest.t; +} + +class VoteRequestIncludeList extends _i1.IncludeList { + VoteRequestIncludeList._({ + _i1.WhereExpressionBuilder? where, + super.limit, + super.offset, + super.orderBy, + super.orderDescending, + super.orderByList, + super.include, + }) { + super.where = where?.call(VoteRequest.t); + } + + @override + Map get includes => include?.includes ?? {}; + + @override + _i1.Table get table => VoteRequest.t; +} + +class VoteRequestRepository { + const VoteRequestRepository._(); + + /// Returns a list of [VoteRequest]s matching the given query parameters. + /// + /// Use [where] to specify which items to include in the return value. + /// If none is specified, all items will be returned. + /// + /// To specify the order of the items use [orderBy] or [orderByList] + /// when sorting by multiple columns. + /// + /// The maximum number of items can be set by [limit]. If no limit is set, + /// all items matching the query will be returned. + /// + /// [offset] defines how many items to skip, after which [limit] (or all) + /// items are read from the database. + /// + /// ```dart + /// var persons = await Persons.db.find( + /// session, + /// where: (t) => t.lastName.equals('Jones'), + /// orderBy: (t) => t.firstName, + /// limit: 100, + /// ); + /// ``` + Future> find( + _i1.Session session, { + _i1.WhereExpressionBuilder? where, + int? limit, + int? offset, + _i1.OrderByBuilder? orderBy, + bool orderDescending = false, + _i1.OrderByListBuilder? orderByList, + _i1.Transaction? transaction, + }) async { + return session.db.find( + where: where?.call(VoteRequest.t), + orderBy: orderBy?.call(VoteRequest.t), + orderByList: orderByList?.call(VoteRequest.t), + orderDescending: orderDescending, + limit: limit, + offset: offset, + transaction: transaction, + ); + } + + /// Returns the first matching [VoteRequest] matching the given query parameters. + /// + /// Use [where] to specify which items to include in the return value. + /// If none is specified, all items will be returned. + /// + /// To specify the order use [orderBy] or [orderByList] + /// when sorting by multiple columns. + /// + /// [offset] defines how many items to skip, after which the next one will be picked. + /// + /// ```dart + /// var youngestPerson = await Persons.db.findFirstRow( + /// session, + /// where: (t) => t.lastName.equals('Jones'), + /// orderBy: (t) => t.age, + /// ); + /// ``` + Future findFirstRow( + _i1.Session session, { + _i1.WhereExpressionBuilder? where, + int? offset, + _i1.OrderByBuilder? orderBy, + bool orderDescending = false, + _i1.OrderByListBuilder? orderByList, + _i1.Transaction? transaction, + }) async { + return session.db.findFirstRow( + where: where?.call(VoteRequest.t), + orderBy: orderBy?.call(VoteRequest.t), + orderByList: orderByList?.call(VoteRequest.t), + orderDescending: orderDescending, + offset: offset, + transaction: transaction, + ); + } + + /// Finds a single [VoteRequest] by its [id] or null if no such row exists. + Future findById( + _i1.Session session, + int id, { + _i1.Transaction? transaction, + }) async { + return session.db.findById( + id, + transaction: transaction, + ); + } + + /// Inserts all [VoteRequest]s in the list and returns the inserted rows. + /// + /// The returned [VoteRequest]s will have their `id` fields set. + /// + /// This is an atomic operation, meaning that if one of the rows fails to + /// insert, none of the rows will be inserted. + Future> insert( + _i1.Session session, + List rows, { + _i1.Transaction? transaction, + }) async { + return session.db.insert( + rows, + transaction: transaction, + ); + } + + /// Inserts a single [VoteRequest] and returns the inserted row. + /// + /// The returned [VoteRequest] will have its `id` field set. + Future insertRow( + _i1.Session session, + VoteRequest row, { + _i1.Transaction? transaction, + }) async { + return session.db.insertRow( + row, + transaction: transaction, + ); + } + + /// Updates all [VoteRequest]s in the list and returns the updated rows. If + /// [columns] is provided, only those columns will be updated. Defaults to + /// all columns. + /// This is an atomic operation, meaning that if one of the rows fails to + /// update, none of the rows will be updated. + Future> update( + _i1.Session session, + List rows, { + _i1.ColumnSelections? columns, + _i1.Transaction? transaction, + }) async { + return session.db.update( + rows, + columns: columns?.call(VoteRequest.t), + transaction: transaction, + ); + } + + /// Updates a single [VoteRequest]. The row needs to have its id set. + /// Optionally, a list of [columns] can be provided to only update those + /// columns. Defaults to all columns. + Future updateRow( + _i1.Session session, + VoteRequest row, { + _i1.ColumnSelections? columns, + _i1.Transaction? transaction, + }) async { + return session.db.updateRow( + row, + columns: columns?.call(VoteRequest.t), + transaction: transaction, + ); + } + + /// Deletes all [VoteRequest]s in the list and returns the deleted rows. + /// This is an atomic operation, meaning that if one of the rows fail to + /// be deleted, none of the rows will be deleted. + Future> delete( + _i1.Session session, + List rows, { + _i1.Transaction? transaction, + }) async { + return session.db.delete( + rows, + transaction: transaction, + ); + } + + /// Deletes a single [VoteRequest]. + Future deleteRow( + _i1.Session session, + VoteRequest row, { + _i1.Transaction? transaction, + }) async { + return session.db.deleteRow( + row, + transaction: transaction, + ); + } + + /// Deletes all rows matching the [where] expression. + Future> deleteWhere( + _i1.Session session, { + required _i1.WhereExpressionBuilder where, + _i1.Transaction? transaction, + }) async { + return session.db.deleteWhere( + where: where(VoteRequest.t), + transaction: transaction, + ); + } + + /// Counts the number of rows matching the [where] expression. If omitted, + /// will return the count of all rows in the table. + Future count( + _i1.Session session, { + _i1.WhereExpressionBuilder? where, + int? limit, + _i1.Transaction? transaction, + }) async { + return session.db.count( + where: where?.call(VoteRequest.t), + limit: limit, + transaction: transaction, + ); + } +} diff --git a/wien_talks/wien_talks_server/lib/src/votes/vote.spy.yaml b/wien_talks/wien_talks_server/lib/src/votes/vote.spy.yaml new file mode 100644 index 0000000..072b1b8 --- /dev/null +++ b/wien_talks/wien_talks_server/lib/src/votes/vote.spy.yaml @@ -0,0 +1,7 @@ +class: Vote +table: vote +fields: + userId: int + createdAt: DateTime + quote: Quote + upvote: bool diff --git a/wien_talks/wien_talks_server/lib/src/votes/vote_request.spy.yaml b/wien_talks/wien_talks_server/lib/src/votes/vote_request.spy.yaml new file mode 100644 index 0000000..e6f5cf5 --- /dev/null +++ b/wien_talks/wien_talks_server/lib/src/votes/vote_request.spy.yaml @@ -0,0 +1,6 @@ +class: VoteRequest +table: vote_request +fields: + userId: int + quote: Quote + upvote: bool diff --git a/wien_talks/wien_talks_server/lib/src/votes/votes_endpoint.dart b/wien_talks/wien_talks_server/lib/src/votes/votes_endpoint.dart new file mode 100644 index 0000000..1e0d874 --- /dev/null +++ b/wien_talks/wien_talks_server/lib/src/votes/votes_endpoint.dart @@ -0,0 +1,21 @@ +import 'package:serverpod/serverpod.dart'; +import 'package:wien_talks_server/src/generated/protocol.dart'; + +class VotesEndpoint extends Endpoint { + Future postVote(Session session, VoteRequest voteRequest) async { + final row = Vote( + createdAt: DateTime.now(), + quote: voteRequest.quote, + upvote: voteRequest.upvote, + userId: voteRequest.userId); + + final persistedVote = await Vote.db.insertRow(session, row); + + return persistedVote; + } + + Future> getAllVotes(Session session) async { + final rows = Vote.db.find(session, limit: 50); + return rows; + } +} diff --git a/wien_talks/wien_talks_server/migrations/20250816171653001/definition.json b/wien_talks/wien_talks_server/migrations/20250816171653001/definition.json new file mode 100644 index 0000000..9efa77a --- /dev/null +++ b/wien_talks/wien_talks_server/migrations/20250816171653001/definition.json @@ -0,0 +1,1800 @@ +{ + "moduleName": "wien_talks", + "tables": [ + { + "name": "quote", + "dartName": "Quote", + "module": "wien_talks", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 6, + "isNullable": false, + "columnDefault": "nextval('quote_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "userId", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "text", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "authorName", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "lat", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "long", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "createdAt", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "visibility", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "upvotes", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "downvotes", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "tags", + "columnType": 8, + "isNullable": true, + "dartType": "List?" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "quote_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + }, + { + "name": "serverpod_cloud_storage", + "dartName": "CloudStorageEntry", + "module": "serverpod", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 6, + "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": 6, + "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": 6, + "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": 6, + "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": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "closing", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "idle", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "granularity", + "columnType": 6, + "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": 6, + "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": 6, + "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": 6, + "isNullable": false, + "columnDefault": "nextval('serverpod_log_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "sessionLogId", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "messageId", + "columnType": 6, + "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": 6, + "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": 6, + "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": 6, + "isNullable": false, + "columnDefault": "nextval('serverpod_message_log_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "sessionLogId", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "messageId", + "columnType": 6, + "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": 6, + "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": 6, + "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": 6, + "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": 6, + "isNullable": false, + "columnDefault": "nextval('serverpod_query_log_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "serverId", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "sessionLogId", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "messageId", + "columnType": 6, + "isNullable": true, + "dartType": "int?" + }, + { + "name": "query", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "duration", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "numRows", + "columnType": 6, + "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": 6, + "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": 6, + "isNullable": false, + "columnDefault": "nextval('serverpod_readwrite_test_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "number", + "columnType": 6, + "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": 6, + "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": 6, + "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": 6, + "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": 6, + "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 + }, + { + "name": "serverpod_auth_key", + "dartName": "AuthKey", + "module": "serverpod_auth", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 6, + "isNullable": false, + "columnDefault": "nextval('serverpod_auth_key_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "userId", + "columnType": 6, + "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_email_auth", + "dartName": "EmailAuth", + "module": "serverpod_auth", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 6, + "isNullable": false, + "columnDefault": "nextval('serverpod_email_auth_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "userId", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "email", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "hash", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_email_auth_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_email_auth_email", + "elements": [ + { + "type": 0, + "definition": "email" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_email_create_request", + "dartName": "EmailCreateAccountRequest", + "module": "serverpod_auth", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 6, + "isNullable": false, + "columnDefault": "nextval('serverpod_email_create_request_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "userName", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "email", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "hash", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "verificationCode", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_email_create_request_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_email_auth_create_account_request_idx", + "elements": [ + { + "type": 0, + "definition": "email" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_email_failed_sign_in", + "dartName": "EmailFailedSignIn", + "module": "serverpod_auth", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 6, + "isNullable": false, + "columnDefault": "nextval('serverpod_email_failed_sign_in_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "email", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "time", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "ipAddress", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_email_failed_sign_in_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_email_failed_sign_in_email_idx", + "elements": [ + { + "type": 0, + "definition": "email" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + }, + { + "indexName": "serverpod_email_failed_sign_in_time_idx", + "elements": [ + { + "type": 0, + "definition": "time" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_email_reset", + "dartName": "EmailReset", + "module": "serverpod_auth", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 6, + "isNullable": false, + "columnDefault": "nextval('serverpod_email_reset_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "userId", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "verificationCode", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "expiration", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_email_reset_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_email_reset_verification_idx", + "elements": [ + { + "type": 0, + "definition": "verificationCode" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_google_refresh_token", + "dartName": "GoogleRefreshToken", + "module": "serverpod_auth", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 6, + "isNullable": false, + "columnDefault": "nextval('serverpod_google_refresh_token_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "userId", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "refreshToken", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_google_refresh_token_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_google_refresh_token_userId_idx", + "elements": [ + { + "type": 0, + "definition": "userId" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_user_image", + "dartName": "UserImage", + "module": "serverpod_auth", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 6, + "isNullable": false, + "columnDefault": "nextval('serverpod_user_image_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "userId", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "version", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "url", + "columnType": 0, + "isNullable": false, + "dartType": "String" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_user_image_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_user_image_user_id", + "elements": [ + { + "type": 0, + "definition": "userId" + }, + { + "type": 0, + "definition": "version" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + }, + { + "name": "serverpod_user_info", + "dartName": "UserInfo", + "module": "serverpod_auth", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 6, + "isNullable": false, + "columnDefault": "nextval('serverpod_user_info_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "userIdentifier", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "userName", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "fullName", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "email", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "created", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "imageUrl", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "scopeNames", + "columnType": 8, + "isNullable": false, + "dartType": "List" + }, + { + "name": "blocked", + "columnType": 1, + "isNullable": false, + "dartType": "bool" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "serverpod_user_info_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + }, + { + "indexName": "serverpod_user_info_user_identifier", + "elements": [ + { + "type": 0, + "definition": "userIdentifier" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": false + }, + { + "indexName": "serverpod_user_info_email", + "elements": [ + { + "type": 0, + "definition": "email" + } + ], + "type": "btree", + "isUnique": false, + "isPrimary": false + } + ], + "managed": true + } + ], + "installedModules": [ + { + "module": "wien_talks", + "version": "20250816171653001" + }, + { + "module": "serverpod", + "version": "20240516151843329" + }, + { + "module": "serverpod_auth", + "version": "20240520102713718" + } + ], + "migrationApiVersion": 1 +} \ No newline at end of file diff --git a/wien_talks/wien_talks_server/migrations/20250816171653001/definition.sql b/wien_talks/wien_talks_server/migrations/20250816171653001/definition.sql new file mode 100644 index 0000000..c3b22fd --- /dev/null +++ b/wien_talks/wien_talks_server/migrations/20250816171653001/definition.sql @@ -0,0 +1,394 @@ +BEGIN; + +-- +-- Class Quote as table quote +-- +CREATE TABLE "quote" ( + "id" bigserial PRIMARY KEY, + "userId" bigint NOT NULL, + "text" text NOT NULL, + "authorName" text, + "lat" double precision NOT NULL, + "long" double precision NOT NULL, + "createdAt" timestamp without time zone NOT NULL, + "visibility" bigint NOT NULL, + "upvotes" bigint NOT NULL, + "downvotes" bigint NOT NULL, + "tags" json +); + +-- +-- Class CloudStorageEntry as table serverpod_cloud_storage +-- +CREATE TABLE "serverpod_cloud_storage" ( + "id" bigserial 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" bigserial 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" bigserial 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" bigserial PRIMARY KEY, + "serverId" text NOT NULL, + "timestamp" timestamp without time zone NOT NULL, + "active" bigint NOT NULL, + "closing" bigint NOT NULL, + "idle" bigint NOT NULL, + "granularity" bigint 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" bigserial 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" bigint 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" bigserial PRIMARY KEY, + "sessionLogId" bigint NOT NULL, + "messageId" bigint, + "reference" text, + "serverId" text NOT NULL, + "time" timestamp without time zone NOT NULL, + "logLevel" bigint NOT NULL, + "message" text NOT NULL, + "error" text, + "stackTrace" text, + "order" bigint 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" bigserial PRIMARY KEY, + "sessionLogId" bigint NOT NULL, + "serverId" text NOT NULL, + "messageId" bigint NOT NULL, + "endpoint" text NOT NULL, + "messageName" text NOT NULL, + "duration" double precision NOT NULL, + "error" text, + "stackTrace" text, + "slow" boolean NOT NULL, + "order" bigint NOT NULL +); + +-- +-- Class MethodInfo as table serverpod_method +-- +CREATE TABLE "serverpod_method" ( + "id" bigserial 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" bigserial 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" bigserial PRIMARY KEY, + "serverId" text NOT NULL, + "sessionLogId" bigint NOT NULL, + "messageId" bigint, + "query" text NOT NULL, + "duration" double precision NOT NULL, + "numRows" bigint, + "error" text, + "stackTrace" text, + "slow" boolean NOT NULL, + "order" bigint 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" bigserial PRIMARY KEY, + "number" bigint NOT NULL +); + +-- +-- Class RuntimeSettings as table serverpod_runtime_settings +-- +CREATE TABLE "serverpod_runtime_settings" ( + "id" bigserial 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" bigserial PRIMARY KEY, + "serverId" text NOT NULL, + "time" timestamp without time zone NOT NULL, + "module" text, + "endpoint" text, + "method" text, + "duration" double precision, + "numQueries" bigint, + "slow" boolean, + "error" text, + "stackTrace" text, + "authenticatedUserId" bigint, + "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"); + +-- +-- Class AuthKey as table serverpod_auth_key +-- +CREATE TABLE "serverpod_auth_key" ( + "id" bigserial PRIMARY KEY, + "userId" bigint 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 EmailAuth as table serverpod_email_auth +-- +CREATE TABLE "serverpod_email_auth" ( + "id" bigserial PRIMARY KEY, + "userId" bigint NOT NULL, + "email" text NOT NULL, + "hash" text NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_email_auth_email" ON "serverpod_email_auth" USING btree ("email"); + +-- +-- Class EmailCreateAccountRequest as table serverpod_email_create_request +-- +CREATE TABLE "serverpod_email_create_request" ( + "id" bigserial PRIMARY KEY, + "userName" text NOT NULL, + "email" text NOT NULL, + "hash" text NOT NULL, + "verificationCode" text NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_email_auth_create_account_request_idx" ON "serverpod_email_create_request" USING btree ("email"); + +-- +-- Class EmailFailedSignIn as table serverpod_email_failed_sign_in +-- +CREATE TABLE "serverpod_email_failed_sign_in" ( + "id" bigserial PRIMARY KEY, + "email" text NOT NULL, + "time" timestamp without time zone NOT NULL, + "ipAddress" text NOT NULL +); + +-- Indexes +CREATE INDEX "serverpod_email_failed_sign_in_email_idx" ON "serverpod_email_failed_sign_in" USING btree ("email"); +CREATE INDEX "serverpod_email_failed_sign_in_time_idx" ON "serverpod_email_failed_sign_in" USING btree ("time"); + +-- +-- Class EmailReset as table serverpod_email_reset +-- +CREATE TABLE "serverpod_email_reset" ( + "id" bigserial PRIMARY KEY, + "userId" bigint NOT NULL, + "verificationCode" text NOT NULL, + "expiration" timestamp without time zone NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_email_reset_verification_idx" ON "serverpod_email_reset" USING btree ("verificationCode"); + +-- +-- Class GoogleRefreshToken as table serverpod_google_refresh_token +-- +CREATE TABLE "serverpod_google_refresh_token" ( + "id" bigserial PRIMARY KEY, + "userId" bigint NOT NULL, + "refreshToken" text NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_google_refresh_token_userId_idx" ON "serverpod_google_refresh_token" USING btree ("userId"); + +-- +-- Class UserImage as table serverpod_user_image +-- +CREATE TABLE "serverpod_user_image" ( + "id" bigserial PRIMARY KEY, + "userId" bigint NOT NULL, + "version" bigint NOT NULL, + "url" text NOT NULL +); + +-- Indexes +CREATE INDEX "serverpod_user_image_user_id" ON "serverpod_user_image" USING btree ("userId", "version"); + +-- +-- Class UserInfo as table serverpod_user_info +-- +CREATE TABLE "serverpod_user_info" ( + "id" bigserial PRIMARY KEY, + "userIdentifier" text NOT NULL, + "userName" text, + "fullName" text, + "email" text, + "created" timestamp without time zone NOT NULL, + "imageUrl" text, + "scopeNames" json NOT NULL, + "blocked" boolean NOT NULL +); + +-- Indexes +CREATE UNIQUE INDEX "serverpod_user_info_user_identifier" ON "serverpod_user_info" USING btree ("userIdentifier"); +CREATE INDEX "serverpod_user_info_email" ON "serverpod_user_info" USING btree ("email"); + +-- +-- 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 wien_talks +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('wien_talks', '20250816171653001', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20250816171653001', "timestamp" = now(); + +-- +-- MIGRATION VERSION FOR serverpod +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('serverpod', '20240516151843329', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240516151843329', "timestamp" = now(); + +-- +-- MIGRATION VERSION FOR serverpod_auth +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('serverpod_auth', '20240520102713718', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240520102713718', "timestamp" = now(); + + +COMMIT; diff --git a/wien_talks/wien_talks_server/migrations/20250816171653001/definition_project.json b/wien_talks/wien_talks_server/migrations/20250816171653001/definition_project.json new file mode 100644 index 0000000..d649d10 --- /dev/null +++ b/wien_talks/wien_talks_server/migrations/20250816171653001/definition_project.json @@ -0,0 +1,107 @@ +{ + "moduleName": "wien_talks", + "tables": [ + { + "name": "quote", + "dartName": "Quote", + "module": "wien_talks", + "schema": "public", + "columns": [ + { + "name": "id", + "columnType": 6, + "isNullable": false, + "columnDefault": "nextval('quote_id_seq'::regclass)", + "dartType": "int?" + }, + { + "name": "userId", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "text", + "columnType": 0, + "isNullable": false, + "dartType": "String" + }, + { + "name": "authorName", + "columnType": 0, + "isNullable": true, + "dartType": "String?" + }, + { + "name": "lat", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "long", + "columnType": 3, + "isNullable": false, + "dartType": "double" + }, + { + "name": "createdAt", + "columnType": 4, + "isNullable": false, + "dartType": "DateTime" + }, + { + "name": "visibility", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "upvotes", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "downvotes", + "columnType": 6, + "isNullable": false, + "dartType": "int" + }, + { + "name": "tags", + "columnType": 8, + "isNullable": true, + "dartType": "List?" + } + ], + "foreignKeys": [], + "indexes": [ + { + "indexName": "quote_pkey", + "elements": [ + { + "type": 0, + "definition": "id" + } + ], + "type": "btree", + "isUnique": true, + "isPrimary": true + } + ], + "managed": true + } + ], + "installedModules": [ + { + "module": "serverpod", + "version": "20240516151843329" + }, + { + "module": "serverpod_auth", + "version": "20240520102713718" + } + ], + "migrationApiVersion": 1 +} \ No newline at end of file diff --git a/wien_talks/wien_talks_server/migrations/20250816171653001/migration.json b/wien_talks/wien_talks_server/migrations/20250816171653001/migration.json new file mode 100644 index 0000000..056118b --- /dev/null +++ b/wien_talks/wien_talks_server/migrations/20250816171653001/migration.json @@ -0,0 +1,5 @@ +{ + "actions": [], + "warnings": [], + "migrationApiVersion": 1 +} \ No newline at end of file diff --git a/wien_talks/wien_talks_server/migrations/20250816171653001/migration.sql b/wien_talks/wien_talks_server/migrations/20250816171653001/migration.sql new file mode 100644 index 0000000..c1ccc46 --- /dev/null +++ b/wien_talks/wien_talks_server/migrations/20250816171653001/migration.sql @@ -0,0 +1,29 @@ +BEGIN; + + +-- +-- MIGRATION VERSION FOR wien_talks +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('wien_talks', '20250816171653001', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20250816171653001', "timestamp" = now(); + +-- +-- MIGRATION VERSION FOR serverpod +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('serverpod', '20240516151843329', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240516151843329', "timestamp" = now(); + +-- +-- MIGRATION VERSION FOR serverpod_auth +-- +INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") + VALUES ('serverpod_auth', '20240520102713718', now()) + ON CONFLICT ("module") + DO UPDATE SET "version" = '20240520102713718', "timestamp" = now(); + + +COMMIT; diff --git a/wien_talks/wien_talks_server/test/integration/test_tools/serverpod_test_tools.dart b/wien_talks/wien_talks_server/test/integration/test_tools/serverpod_test_tools.dart index 58e233c..e2e9136 100644 --- a/wien_talks/wien_talks_server/test/integration/test_tools/serverpod_test_tools.dart +++ b/wien_talks/wien_talks_server/test/integration/test_tools/serverpod_test_tools.dart @@ -105,7 +105,9 @@ void withServerpod( } class TestEndpoints { - late final _ShowLatestNewsWidget showLatestNewsWidget; + late final _QuoteEndpoint quote; + + late final _VotesEndpoint votes; } class _InternalTestEndpoints extends TestEndpoints @@ -115,15 +117,22 @@ class _InternalTestEndpoints extends TestEndpoints _i2.SerializationManager serializationManager, _i2.EndpointDispatch endpoints, ) { - showLatestNewsWidget = _ShowLatestNewsWidget( + quote = _QuoteEndpoint( + endpoints, + serializationManager, + ); + votes = _VotesEndpoint( endpoints, serializationManager, ); } } -class _ShowLatestNewsWidget { - _ShowLatestNewsWidget(this._endpointDispatch, this._serializationManager); +class _QuoteEndpoint { + _QuoteEndpoint( + this._endpointDispatch, + this._serializationManager, + ); final _i2.EndpointDispatch _endpointDispatch; @@ -136,23 +145,21 @@ class _ShowLatestNewsWidget { return _i1.callAwaitableFunctionAndHandleExceptions(() async { var _localUniqueSession = (sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild( - endpoint: 'showLatestNewsWidget', - method: 'createQuote', - ); + endpoint: 'quote', + method: 'createQuote', + ); try { var _localCallContext = await _endpointDispatch.getMethodCallContext( createSessionCallback: (_) => _localUniqueSession, - endpointPath: 'showLatestNewsWidget', + endpointPath: 'quote', methodName: 'createQuote', parameters: _i1.testObjectToJson({'req': req}), serializationManager: _serializationManager, ); - var _localReturnValue = - await (_localCallContext.method.call( - _localUniqueSession, - _localCallContext.arguments, - ) - as _i3.Future<_i4.Quote>); + var _localReturnValue = await (_localCallContext.method.call( + _localUniqueSession, + _localCallContext.arguments, + ) as _i3.Future<_i4.Quote>); return _localReturnValue; } finally { await _localUniqueSession.close(); @@ -167,23 +174,21 @@ class _ShowLatestNewsWidget { return _i1.callAwaitableFunctionAndHandleExceptions(() async { var _localUniqueSession = (sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild( - endpoint: 'showLatestNewsWidget', - method: 'updateQuote', - ); + endpoint: 'quote', + method: 'updateQuote', + ); try { var _localCallContext = await _endpointDispatch.getMethodCallContext( createSessionCallback: (_) => _localUniqueSession, - endpointPath: 'showLatestNewsWidget', + endpointPath: 'quote', methodName: 'updateQuote', parameters: _i1.testObjectToJson({'quote': quote}), serializationManager: _serializationManager, ); - var _localReturnValue = - await (_localCallContext.method.call( - _localUniqueSession, - _localCallContext.arguments, - ) - as _i3.Future); + var _localReturnValue = await (_localCallContext.method.call( + _localUniqueSession, + _localCallContext.arguments, + ) as _i3.Future); return _localReturnValue; } finally { await _localUniqueSession.close(); @@ -192,29 +197,92 @@ class _ShowLatestNewsWidget { } _i3.Future> getAllQuotes( - _i1.TestSessionBuilder sessionBuilder, { - required int limit, - }) async { + _i1.TestSessionBuilder sessionBuilder) async { return _i1.callAwaitableFunctionAndHandleExceptions(() async { var _localUniqueSession = (sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild( - endpoint: 'showLatestNewsWidget', - method: 'getAllQuotes', - ); + endpoint: 'quote', + method: 'getAllQuotes', + ); try { var _localCallContext = await _endpointDispatch.getMethodCallContext( createSessionCallback: (_) => _localUniqueSession, - endpointPath: 'showLatestNewsWidget', + endpointPath: 'quote', methodName: 'getAllQuotes', - parameters: _i1.testObjectToJson({'limit': limit}), + parameters: _i1.testObjectToJson({}), serializationManager: _serializationManager, ); - var _localReturnValue = - await (_localCallContext.method.call( - _localUniqueSession, - _localCallContext.arguments, - ) - as _i3.Future>); + var _localReturnValue = await (_localCallContext.method.call( + _localUniqueSession, + _localCallContext.arguments, + ) as _i3.Future>); + return _localReturnValue; + } finally { + await _localUniqueSession.close(); + } + }); + } +} + +class _VotesEndpoint { + _VotesEndpoint( + this._endpointDispatch, + this._serializationManager, + ); + + final _i2.EndpointDispatch _endpointDispatch; + + final _i2.SerializationManager _serializationManager; + + _i3.Future<_i6.Vote> postVote( + _i1.TestSessionBuilder sessionBuilder, + _i7.VoteRequest voteRequest, + ) async { + return _i1.callAwaitableFunctionAndHandleExceptions(() async { + var _localUniqueSession = + (sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild( + endpoint: 'votes', + method: 'postVote', + ); + try { + var _localCallContext = await _endpointDispatch.getMethodCallContext( + createSessionCallback: (_) => _localUniqueSession, + endpointPath: 'votes', + methodName: 'postVote', + parameters: _i1.testObjectToJson({'voteRequest': voteRequest}), + serializationManager: _serializationManager, + ); + var _localReturnValue = await (_localCallContext.method.call( + _localUniqueSession, + _localCallContext.arguments, + ) as _i3.Future<_i6.Vote>); + return _localReturnValue; + } finally { + await _localUniqueSession.close(); + } + }); + } + + _i3.Future> getAllVotes( + _i1.TestSessionBuilder sessionBuilder) async { + return _i1.callAwaitableFunctionAndHandleExceptions(() async { + var _localUniqueSession = + (sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild( + endpoint: 'votes', + method: 'getAllVotes', + ); + try { + var _localCallContext = await _endpointDispatch.getMethodCallContext( + createSessionCallback: (_) => _localUniqueSession, + endpointPath: 'votes', + methodName: 'getAllVotes', + parameters: _i1.testObjectToJson({}), + serializationManager: _serializationManager, + ); + var _localReturnValue = await (_localCallContext.method.call( + _localUniqueSession, + _localCallContext.arguments, + ) as _i3.Future>); return _localReturnValue; } finally { await _localUniqueSession.close();