-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[starts #187584911] Seller statistics per timeframe (#54)
* [starts #187584911] Seller statistics per timeframe * [finishes #187584911] Seller statistics per timeframe * Seller-statistics updated
- Loading branch information
1 parent
778487e
commit 862e4fd
Showing
30 changed files
with
1,618 additions
and
870 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 17 additions & 18 deletions
35
...migrations/20240601223523-create-shops.ts → ...ions/20240521161805-create-shops-table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,45 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { DataTypes, QueryInterface} from "sequelize"; | ||
import { QueryInterface, DataTypes } from "sequelize"; | ||
|
||
export default { | ||
up: async (queryInterface: QueryInterface, Sequelize: any) => { | ||
export = { | ||
up: async (queryInterface: QueryInterface) => { | ||
await queryInterface.createTable("shops", { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4 | ||
}, | ||
name: { | ||
allowNull: false, | ||
type: DataTypes.STRING(128) | ||
defaultValue: DataTypes.UUIDV4, | ||
primaryKey: true | ||
}, | ||
userId: { | ||
allowNull: false, | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
references: { | ||
model: "users", | ||
key: "id" | ||
}, | ||
onDelete: "CASCADE" | ||
onUpdate: "CASCADE" | ||
}, | ||
name: { | ||
type: DataTypes.STRING(280), | ||
allowNull: true | ||
}, | ||
description: { | ||
type: DataTypes.STRING, | ||
type: DataTypes.STRING(560), | ||
allowNull: true | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: DataTypes.DATE, | ||
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP") | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: DataTypes.DATE, | ||
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP") | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW | ||
} | ||
}); | ||
}, | ||
|
||
down: async (queryInterface: QueryInterface) => { | ||
await queryInterface.dropTable("shops"); | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { QueryInterface, DataTypes } from "sequelize"; | ||
|
||
export = { | ||
up: async (queryInterface: QueryInterface) => { | ||
await queryInterface.createTable("carts", { | ||
id: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
defaultValue: DataTypes.UUIDV4, | ||
primaryKey: true | ||
}, | ||
userId: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
references: { | ||
model: "users", | ||
key: "id" | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "CASCADE" | ||
}, | ||
status: { | ||
type: DataTypes.STRING, | ||
allowNull: false | ||
}, | ||
createdAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW | ||
}, | ||
updatedAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW | ||
} | ||
}); | ||
}, | ||
|
||
down: async (queryInterface: QueryInterface) => { | ||
await queryInterface.dropTable("carts"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { QueryInterface, DataTypes } from "sequelize"; | ||
|
||
export = { | ||
up: async (queryInterface: QueryInterface) => { | ||
await queryInterface.createTable("orders", { | ||
id: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
defaultValue: DataTypes.UUIDV4, | ||
primaryKey: true | ||
}, | ||
shopId: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
references: { | ||
model: "shops", | ||
key: "id" | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "CASCADE" | ||
}, | ||
cartId: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
references: { | ||
model: "carts", | ||
key: "id" | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "CASCADE" | ||
}, | ||
paymentMethodId: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false | ||
}, | ||
orderDate: { | ||
type: DataTypes.DATE, | ||
allowNull: true, | ||
defaultValue: DataTypes.NOW | ||
}, | ||
status: { | ||
type: DataTypes.STRING, | ||
allowNull: false | ||
}, | ||
createdAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW | ||
}, | ||
updatedAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW | ||
} | ||
}); | ||
}, | ||
|
||
down: async (queryInterface: QueryInterface) => { | ||
await queryInterface.dropTable("orders"); | ||
} | ||
}; |
64 changes: 64 additions & 0 deletions
64
src/databases/migrations/20240607150545-create-cart-products.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { QueryInterface, DataTypes } from "sequelize"; | ||
|
||
export = { | ||
up: async (queryInterface: QueryInterface) => { | ||
await queryInterface.createTable("cart_products", { | ||
id: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
defaultValue: DataTypes.UUIDV4, | ||
primaryKey: true | ||
}, | ||
productId: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
references: { | ||
model: "Products", | ||
key: "id" | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "CASCADE" | ||
}, | ||
cartId: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
references: { | ||
model: "carts", | ||
key: "id" | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "CASCADE" | ||
}, | ||
quantity: { | ||
type: DataTypes.INTEGER, | ||
allowNull: true | ||
}, | ||
discount: { | ||
type: DataTypes.FLOAT, | ||
allowNull: true | ||
}, | ||
price: { | ||
type: DataTypes.FLOAT, | ||
allowNull: false | ||
}, | ||
totalPrice: { | ||
type: DataTypes.FLOAT, | ||
allowNull: false | ||
}, | ||
createdAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW | ||
}, | ||
updatedAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW | ||
} | ||
}); | ||
}, | ||
|
||
down: async (queryInterface: QueryInterface) => { | ||
await queryInterface.dropTable("cart_products"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable require-jsdoc */ | ||
import { Model, DataTypes } from "sequelize"; | ||
import sequelizeConnection from "../config/db.config"; | ||
|
||
export interface CartAttributes { | ||
id: number; | ||
userId: number; | ||
status: string; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
} | ||
|
||
class Cart extends Model<CartAttributes> implements CartAttributes { | ||
declare id: number; | ||
declare userId: number; | ||
declare status: string; | ||
declare createdAt: Date; | ||
declare updatedAt: Date; | ||
|
||
static associate(models: any) { | ||
Cart.belongsTo(models.User, { foreignKey: "userId", as: "buyer" }); | ||
} | ||
} | ||
|
||
Cart.init( | ||
{ | ||
id: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
defaultValue: DataTypes.UUIDV4, | ||
primaryKey: true | ||
}, | ||
userId: { | ||
type: new DataTypes.UUID, | ||
allowNull: false | ||
}, | ||
status: { | ||
type: new DataTypes.STRING, | ||
allowNull: false | ||
}, | ||
createdAt: { | ||
field: "createdAt", | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW | ||
}, | ||
updatedAt: { | ||
field: "updatedAt", | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW | ||
} | ||
}, | ||
{ | ||
sequelize: sequelizeConnection, | ||
tableName: "carts", | ||
timestamps: true, | ||
modelName: "Cart" | ||
} | ||
); | ||
|
||
export default Cart; |
Oops, something went wrong.