-
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.
[Finishes #187584924] Seller Create/Add a product (#48)
* [Delivers #187584924] Seller Create/Add a product * updated ReaderMe file * Rebased on develop
- Loading branch information
AimePazzo
authored
Jun 6, 2024
1 parent
5a3356d
commit dad2ece
Showing
34 changed files
with
1,967 additions
and
684 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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,46 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { DataTypes, QueryInterface} from "sequelize"; | ||
|
||
export default { | ||
up: async (queryInterface: QueryInterface, Sequelize: any) => { | ||
await queryInterface.createTable("shops", { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4 | ||
}, | ||
name: { | ||
allowNull: false, | ||
type: DataTypes.STRING(128) | ||
}, | ||
userId: { | ||
allowNull: false, | ||
type: DataTypes.UUID, | ||
references: { | ||
model: "users", | ||
key: "id" | ||
}, | ||
onDelete: "CASCADE" | ||
}, | ||
description: { | ||
type: DataTypes.STRING, | ||
allowNull: true | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: DataTypes.DATE, | ||
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP") | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: DataTypes.DATE, | ||
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP") | ||
} | ||
}); | ||
}, | ||
|
||
down: async (queryInterface: QueryInterface) => { | ||
await queryInterface.dropTable("shops"); | ||
} | ||
}; |
81 changes: 81 additions & 0 deletions
81
src/databases/migrations/20240601223524-create-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,81 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { QueryInterface, DataTypes } from "sequelize"; | ||
|
||
export default { | ||
up: async (queryInterface: QueryInterface, Sequelize: any) => { | ||
await queryInterface.createTable("Products", { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4 | ||
}, | ||
shopId: { | ||
allowNull: false, | ||
type: DataTypes.UUID, | ||
references: { | ||
model: "shops", | ||
key: "id" | ||
}, | ||
onDelete: "CASCADE" | ||
}, | ||
name: { | ||
allowNull: false, | ||
type: DataTypes.STRING | ||
}, | ||
description: { | ||
type: DataTypes.STRING, | ||
allowNull: true | ||
}, | ||
price: { | ||
allowNull: false, | ||
type: DataTypes.DECIMAL(10, 2) | ||
}, | ||
discount: { | ||
type: DataTypes.STRING, | ||
allowNull: true | ||
}, | ||
category: { | ||
allowNull: false, | ||
type: DataTypes.STRING | ||
}, | ||
expiryDate: { | ||
type: DataTypes.DATE | ||
}, | ||
expired: { | ||
type: DataTypes.BOOLEAN, | ||
defaultValue: false | ||
}, | ||
bonus: { | ||
type: DataTypes.STRING | ||
}, | ||
images: { | ||
type: DataTypes.ARRAY(DataTypes.STRING) | ||
}, | ||
quantity: { | ||
allowNull: false, | ||
type: DataTypes.INTEGER, | ||
defaultValue: 0 | ||
}, | ||
isAvailable: { | ||
type: DataTypes.STRING(128), | ||
allowNull: false, | ||
defaultValue: "available" | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: DataTypes.DATE, | ||
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP") | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: DataTypes.DATE, | ||
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP") | ||
} | ||
}); | ||
}, | ||
|
||
down: async (queryInterface: QueryInterface) => { | ||
await queryInterface.dropTable("Products"); | ||
} | ||
}; |
Oops, something went wrong.