diff --git a/client/src/actions/index.js b/client/src/actions/index.js index 14ad591..ae89aac 100644 --- a/client/src/actions/index.js +++ b/client/src/actions/index.js @@ -27,6 +27,7 @@ export const fetchPin = () => async dispatch => { export const fetchMedia = () => async dispatch => { dispatch({type: types.SET_LOADING, payload: true}); + console.log('I WAS CALLED MIKE--'); const res = await axios.get('/api/plex/import/all'); console.log('fetchMedia', res); dispatch({type: types.SET_LOADING, payload: false}); diff --git a/server/db/migrations/20190224045315-create-plex-library.js b/server/db/migrations/20190224045315-create-plex-library.js index c4734cd..4c2d64a 100644 --- a/server/db/migrations/20190224045315-create-plex-library.js +++ b/server/db/migrations/20190224045315-create-plex-library.js @@ -9,7 +9,6 @@ module.exports = { }, title: { type: Sequelize.STRING, - unique: true, }, type: { type: Sequelize.STRING, diff --git a/server/db/migrations/20190224045418-create-plex-section.js b/server/db/migrations/20190224045418-create-plex-section.js index 6cd62b0..733a682 100644 --- a/server/db/migrations/20190224045418-create-plex-section.js +++ b/server/db/migrations/20190224045418-create-plex-section.js @@ -9,7 +9,6 @@ module.exports = { }, title: { type: Sequelize.STRING, - unique: true, }, type: { type: Sequelize.STRING, diff --git a/server/db/models/plexSection.js b/server/db/models/plexSection.js index a1f7681..bd72974 100644 --- a/server/db/models/plexSection.js +++ b/server/db/models/plexSection.js @@ -2,11 +2,18 @@ module.exports = (sequelize, DataTypes) => { const PlexSection = sequelize.define( 'PlexSection', { - title: {type: DataTypes.STRING, unique: true}, + title: DataTypes.STRING, type: DataTypes.STRING, key: DataTypes.INTEGER, }, - {}, + { + indexes: [ + { + unique: true, + fields: ['title', 'UserId'], + }, + ], + }, ); PlexSection.associate = function(models) { PlexSection.belongsTo(models.User); diff --git a/server/db/models/plexlibrary.js b/server/db/models/plexlibrary.js index d45feb1..2312798 100644 --- a/server/db/models/plexlibrary.js +++ b/server/db/models/plexlibrary.js @@ -12,7 +12,14 @@ module.exports = (sequelize, DataTypes) => { year: DataTypes.INTEGER, genre: DataTypes.STRING, }, - {}, + { + indexes: [ + { + unique: true, + fields: ['title', 'UserId'], + }, + ], + }, ); // eslint-disable-next-line no-unused-vars PlexLibrary.associate = function(models) { diff --git a/server/services/plex/importData.js b/server/services/plex/importData.js index d15fe75..31836fd 100644 --- a/server/services/plex/importData.js +++ b/server/services/plex/importData.js @@ -38,6 +38,7 @@ const importTvPosters = async user => { }; const createSections = (sections, user) => { + console.log('Creating Sections'); return Promise.map(sections, section => { return models.PlexSection.upsert( {