migrations get automatically applied when running proj

Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
haraldnilsen 2023-10-03 09:18:04 +02:00
parent 1c19ca4ee2
commit 5cfc2653bb
5 changed files with 18 additions and 5 deletions
backend
frontend/src
api
components/MovieTableRow

View file

@ -71,7 +71,9 @@ public class MovieController: ControllerBase
return StatusCode(204, "No Content");
}
return Ok(resultTake);
MovieResponse Response = new MovieResponse("OK", resultTake.Count(), resultTake);
return Ok(Response);
}
catch (Exception ex)
{

View file

@ -4,9 +4,16 @@ namespace backend;
public class MovieResponse
{
public MovieResponse(string Response, int TotalResults, IEnumerable<MovieDB> Search) {
this.Response = Response;
this.TotalResults = TotalResults;
this.Search = Search;
}
public string Response { get; set; }
public string TotalResults { get; set; }
public int TotalResults { get; set; }
public List<Movie> Search { get; set; }
public IEnumerable<MovieDB> Search { get; set; }
}

View file

@ -38,6 +38,11 @@ using (var scope = services.CreateScope())
var context = scope.ServiceProvider.GetRequiredService<MovieDbContext>();
context.Database.EnsureCreated();
using (context)
{
context.Database.Migrate();
}
// Check if movies are already inserted to avoid duplicate insertion
if (!context.Movies.Any())
{

View file

@ -1,4 +1,4 @@
import { movieObject, movieResponse } from '../types/movie'
import { movieResponse } from '../types/movie'
//const API_MOVIE_KEY = import.meta.env.VITE_MOVIE_API_KEY

View file

@ -1,7 +1,6 @@
import type { movieObject } from '../../types/movie'
import Modal from 'react-modal'
import q from 'qjuul'
import { useState } from 'react'
interface MovieTableRowProps {
movie: movieObject