Skip to content

Commit

Permalink
se actualizaron los cambios de la rama development
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvaro1599 committed Sep 17, 2022
1 parent 6df0c46 commit ef27728
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 0 deletions.
3 changes: 3 additions & 0 deletions controllers/slider.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class SlidersController{}

module.exports = SlidersController;
45 changes: 45 additions & 0 deletions migrations/20220915021748-create-slide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('Slides', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
imageUrl: {
allowNull:false,
type: Sequelize.STRING
},
text: {
allowNull:false,
type: Sequelize.STRING
},
order: {
allowNull:false,
type: Sequelize.INTEGER
},
organizationId: {
type: Sequelize.INTEGER,
references: {
model: 'Organizations',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'SET NULL'
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
},
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('Slides');
}
};
51 changes: 51 additions & 0 deletions models/slide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class Slide extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
// define association here
Slide.belongsTo(models.Organization, {
as: 'organization',
foreignKey: 'id',
sourceKey: 'organizationId',
})
}
};
Slide.init({
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
allowNull: false,
primaryKey:true
},
imageUrl: {
allowNull: false,
type: DataTypes.STRING
},
text: {
allowNull: false,
type: DataTypes.STRING
},
order: {
allowNull: false,
type: DataTypes.INTEGER
},
organizationId: {
type: DataTypes.INTEGER
},
deletedAt: DataTypes.DATE
}, {
sequelize,
modelName: 'Slide',
timestamps: true,
paranoid: true
});
return Slide;
};
67 changes: 67 additions & 0 deletions seeders/20220915023136-create-slides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
'use strict';

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.bulkInsert('Slides', [{
imageUrl: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
text: 'this is a text',
order: 1,
organizationId: 1,
createdAt: new Date,
updatedAt: new Date
},{
imageUrl: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
text: 'this is a text1',
order: 2,
organizationId: 2,
createdAt: new Date,
updatedAt: new Date
},{
imageUrl: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
text: 'this is a text2',
order: 3,
organizationId: 2,
createdAt: new Date,
updatedAt: new Date
},{
imageUrl: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
text: 'this is a text3',
order: 4,
organizationId: 2,
createdAt: new Date,
updatedAt: new Date
},{
imageUrl: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
text: 'this is a text4',
order: 5,
organizationId: 1,
createdAt: new Date,
updatedAt: new Date
},{
imageUrl: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
text: 'this is a text5',
order: 6,
organizationId: 1,
createdAt: new Date,
updatedAt: new Date
},{
imageUrl: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
text: 'this is a text6',
order: 7,
organizationId: 1,
createdAt: new Date,
updatedAt: new Date
},{
imageUrl: 'https://www.designevo.com/res/templates/thumb_small/colorful-hand-and-warm-community.png',
text: 'this is a text7',
order: 8,
organizationId: 1,
createdAt: new Date,
updatedAt: new Date
}], {});
},

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

0 comments on commit ef27728

Please sign in to comment.