Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ot 23 members model migration controller #25

Merged
merged 5 commits into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions controllers/member.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { Members: Member } = require("../models").sequelize.models

class MemberController {

}

module.exports = MemberController
51 changes: 51 additions & 0 deletions migrations/20220914211317-create-member.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('Members', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
name: {
allowNull: false,
type: Sequelize.STRING
},
facebookUrl: {
allowNull: true,
type: Sequelize.STRING
},
instagramUrl: {
allowNull: true,
type: Sequelize.STRING
},
linkedinUrl: {
allowNull: true,
type: Sequelize.STRING
},
image: {
allowNull: false,
type: Sequelize.STRING
},
description: {
allowNull: true,
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
},
deletedAt: {
type: Sequelize.DATE
}
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('Members');
}
};
54 changes: 54 additions & 0 deletions models/member.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class Member extends Model {
/**
* Helper method for defining associations.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: borrar comentarios innecesarios.

* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
// define association here
}
};
Member.init({
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
name: {
allowNull: false,
type: DataTypes.STRING
},
facebookUrl: {
allowNull: true,
type: DataTypes.STRING
},
instagramUrl: {
allowNull: true,
type: DataTypes.STRING
},
linkedinUrl: {
allowNull: true,
type: DataTypes.STRING
},
image: {
allowNull: false,
type: DataTypes.STRING
},
description: {
allowNull: true,
type: DataTypes.STRING
},
deletedAt: DataTypes.DATE
}, {
sequelize,
modelName: 'Member',
paranoid: true
});
return Member;
};
78 changes: 78 additions & 0 deletions seeders/20220914235547-create-member.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
'use strict';

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.bulkInsert('Members', [{
name: 'Member',
facebookUrl: 'https://www.facebook.com/member/',
instagramUrl: 'https://www.instagram.com/member/',
linkedinUrl: 'https://www.linkedin.com/member/',
description: "this is a description",
image: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
createdAt: new Date,
updatedAt: new Date,
},
{
name: 'Member1',
facebookUrl: 'https://www.facebook.com/member1/',
instagramUrl: 'https://www.instagram.com/member1/',
linkedinUrl: 'https://www.linkedin.com/member1/',
image: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
createdAt: new Date,
updatedAt: new Date,
}, {
name: 'Member2',
facebookUrl: 'https://www.facebook.com/member2/',
instagramUrl: 'https://www.instagram.com/member2/',
linkedinUrl: 'https://www.linkedin.com/member2/',
description: "this is a description",
image: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
createdAt: new Date,
updatedAt: new Date,
}
, {
name: 'Member3',
facebookUrl: 'https://www.facebook.com/member3/',
instagramUrl: 'https://www.instagram.com/member3/',
linkedinUrl: 'https://www.linkedin.com/member3/',
description: "this is a description",
image: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
createdAt: new Date,
updatedAt: new Date,
}
, {
name: 'Member4',
facebookUrl: 'https://www.facebook.com/member4/',
instagramUrl: 'https://www.instagram.com/member4/',
linkedinUrl: 'https://www.linkedin.com/member4/',
description: "this is a description",
image: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
createdAt: new Date,
updatedAt: new Date,
}
, {
name: 'Member5',
facebookUrl: 'https://www.facebook.com/member5/',
instagramUrl: 'https://www.instagram.com/member5/',
linkedinUrl: 'https://www.linkedin.com/member5/',
description: "this is a description",
image: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
createdAt: new Date,
updatedAt: new Date,
},
{
name: 'Member6',
facebookUrl: 'https://www.facebook.com/member6/',
instagramUrl: 'https://www.instagram.com/member6/',
linkedinUrl: 'https://www.linkedin.com/member6/',
description: "this is a description",
image: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
createdAt: new Date,
updatedAt: new Date,
}], {});
},

down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('Members', null, {});
}
};