Added online schedulling

This commit is contained in:
Torsten Schulz
2024-09-12 17:34:46 +02:00
parent 28524f4308
commit 07477d991b
105 changed files with 4475 additions and 7563 deletions

42
backend/models/League.js Normal file
View File

@@ -0,0 +1,42 @@
import { DataTypes } from 'sequelize';
import sequelize from '../database.js';
import Season from './Season.js';
const League = sequelize.define('League', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
},
name: {
type: DataTypes.STRING,
allowNull: false,
},
seasonId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: Season,
key: 'id',
},
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
},
clubId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: 'clubs',
key: 'id',
},
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
},
}, {
underscored: true,
tableName: 'league',
timestamps: true,
});
export default League;

View File

@@ -0,0 +1,33 @@
import { DataTypes } from 'sequelize';
import sequelize from '../database.js';
const Location = sequelize.define('Location', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
},
name: {
type: DataTypes.STRING,
allowNull: false,
},
address: {
type: DataTypes.STRING,
allowNull: true,
},
city: {
type: DataTypes.STRING,
allowNull: false,
},
zip: {
type: DataTypes.STRING,
allowNull: false,
},
}, {
underscored: true,
tableName: 'location',
timestamps: true,
});
export default Location;

78
backend/models/Match.js Normal file
View File

@@ -0,0 +1,78 @@
import { DataTypes } from 'sequelize';
import sequelize from '../database.js';
import Club from './Club.js';
import League from './League.js';
import Team from './Team.js';
import Season from './Season.js';
import Location from './Location.js';
const Match = sequelize.define('Match', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
},
date: {
type: DataTypes.DATE,
allowNull: false,
},
time: {
type: DataTypes.TIME,
allowNull: true,
},
seasonId: {
type: DataTypes.INTEGER,
references: {
model: Season,
key: 'id',
},
allowNull: false,
},
locationId: {
type: DataTypes.INTEGER,
references: {
model: Location,
key: 'id',
},
allowNull: false,
},
homeTeamId: {
type: DataTypes.INTEGER,
references: {
model: Team,
key: 'id',
},
allowNull: false,
},
guestTeamId: {
type: DataTypes.INTEGER,
references: {
model: Team,
key: 'id',
},
allowNull: false,
},
leagueId: {
type: DataTypes.INTEGER,
references: {
model: League,
key: 'id',
},
allowNull: false,
},
clubId: {
type: DataTypes.INTEGER,
references: {
model: Club,
key: 'id',
},
allowNull: false,
},
}, {
underscored: true,
tableName: 'match',
timestamps: true,
});
export default Match;

22
backend/models/Season.js Normal file
View File

@@ -0,0 +1,22 @@
import { DataTypes } from 'sequelize';
import sequelize from '../database.js';
const Season = sequelize.define('Season', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
},
season: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
},
}, {
underscored: true,
tableName: 'season',
timestamps: true,
});
export default Season;

32
backend/models/Team.js Normal file
View File

@@ -0,0 +1,32 @@
import { DataTypes } from 'sequelize';
import sequelize from '../database.js';
import Club from './Club.js';
const Team = sequelize.define('Team', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
},
name: {
type: DataTypes.STRING,
allowNull: false,
},
clubId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: Club,
key: 'id',
},
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
},
}, {
underscored: true,
tableName: 'team',
timestamps: true,
});
export default Team;

View File

@@ -14,6 +14,11 @@ import DiaryMemberNote from './DiaryMemberNote.js';
import DiaryMemberTag from './DiaryMemberTag.js';
import PredefinedActivity from './PredefinedActivity.js';
import DiaryDateActivity from './DiaryDateActivity.js';
import Match from './Match.js';
import League from './League.js';
import Team from './Team.js';
import Season from './Season.js';
import Location from './Location.js';
User.hasMany(Log, { foreignKey: 'userId' });
Log.belongsTo(User, { foreignKey: 'userId' });
@@ -57,6 +62,29 @@ DiaryDateActivity.belongsTo(DiaryDate, { foreignKey: 'diaryDateId', as: 'diaryDa
PredefinedActivity.hasMany(DiaryDateActivity, { foreignKey: 'predefinedActivityId', as: 'predefinedActivities' });
DiaryDateActivity.belongsTo(PredefinedActivity, { foreignKey: 'predefinedActivityId', as: 'predefinedActivity' });
Club.hasMany(Match, { foreignKey: 'clubId', as: 'matches' });
Match.belongsTo(Club, { foreignKey: 'clubId', as: 'club' });
League.hasMany(Match, { foreignKey: 'leagueId', as: 'leagueMatches' });
Match.belongsTo(League, { foreignKey: 'leagueId', as: 'leagueDetails' });
Team.hasMany(Match, { foreignKey: 'homeTeamId', as: 'homeMatches' });
Team.hasMany(Match, { foreignKey: 'guestTeamId', as: 'guestMatches' });
Match.belongsTo(Team, { foreignKey: 'homeTeamId', as: 'homeTeam' });
Match.belongsTo(Team, { foreignKey: 'guestTeamId', as: 'guestTeam' });
Club.hasMany(Team, { foreignKey: 'clubId', as: 'teams' });
Team.belongsTo(Club, { foreignKey: 'clubId', as: 'club' });
Club.hasMany(League, { foreignKey: 'clubId', as: 'leagues' });
League.belongsTo(Club, { foreignKey: 'clubId', as: 'club' });
Match.belongsTo(Season, { foreignKey: 'seasonId', as: 'season' });
Season.hasMany(Match, { foreignKey: 'seasonId', as: 'matches' });
Match.belongsTo(Location, { foreignKey: 'locationId', as: 'location' });
Location.hasMany(Match, { foreignKey: 'locationId', as: 'matches' });
export {
User,
Log,
@@ -75,4 +103,7 @@ export {
DiaryMemberTag,
PredefinedActivity,
DiaryDateActivity,
Match,
League,
Team,
};