Bdd1 PGSQL
continuous-integration/drone/push Build is failing Details

master
Leni BEAULATON 2 weeks ago
parent f1e5399674
commit dd5461e3e4

@ -1,496 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace StubbedContextLib.Migrations
{
/// <inheritdoc />
public partial class myFirstMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "images",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ImgPath = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_images", x => x.Id);
});
migrationBuilder.CreateTable(
name: "question",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Text = table.Column<string>(type: "TEXT", maxLength: 200, nullable: false),
AnswerA = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
AnswerB = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
AnswerC = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
AnswerD = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
CorrectAnswer = table.Column<string>(type: "TEXT", maxLength: 1, nullable: false),
IsValid = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_question", x => x.Id);
});
migrationBuilder.CreateTable(
name: "sources",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Title = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Year = table.Column<int>(type: "INTEGER", nullable: false),
TypeSrc = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_sources", x => x.Id);
});
migrationBuilder.CreateTable(
name: "characters",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
IdImage = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_characters", x => x.Id);
table.ForeignKey(
name: "FK_characters_images_IdImage",
column: x => x.IdImage,
principalTable: "images",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "quizzes",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Title = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
IdImage = table.Column<int>(type: "INTEGER", nullable: false),
NbQuestion = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_quizzes", x => x.Id);
table.ForeignKey(
name: "FK_quizzes_images_IdImage",
column: x => x.IdImage,
principalTable: "images",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "users",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
UserName = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
Email = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
Password = table.Column<string>(type: "TEXT", maxLength: 200, nullable: false),
IdImage = table.Column<int>(type: "INTEGER", nullable: false),
Created = table.Column<DateTime>(type: "date", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_users", x => x.Id);
table.ForeignKey(
name: "FK_users_images_IdImage",
column: x => x.IdImage,
principalTable: "images",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "QuizQuestion",
columns: table => new
{
IdQuiz = table.Column<int>(type: "INTEGER", nullable: false),
IdQuestion = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_QuizQuestion", x => new { x.IdQuestion, x.IdQuiz });
table.ForeignKey(
name: "FK_QuizQuestion_question_IdQuestion",
column: x => x.IdQuestion,
principalTable: "question",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_QuizQuestion_quizzes_IdQuiz",
column: x => x.IdQuiz,
principalTable: "quizzes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "admins",
columns: table => new
{
IdUsers = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
UserId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_admins", x => x.IdUsers);
table.ForeignKey(
name: "FK_admins_users_UserId",
column: x => x.UserId,
principalTable: "users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "quotes",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Content = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Likes = table.Column<int>(type: "INTEGER", nullable: false),
Langage = table.Column<int>(type: "INTEGER", nullable: false),
IsValid = table.Column<bool>(type: "INTEGER", nullable: false),
IdCharacter = table.Column<int>(type: "INTEGER", nullable: false),
IdSource = table.Column<int>(type: "INTEGER", nullable: false),
IdUsersPropose = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_quotes", x => x.Id);
table.ForeignKey(
name: "FK_quotes_characters_IdCharacter",
column: x => x.IdCharacter,
principalTable: "characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_quotes_sources_IdSource",
column: x => x.IdSource,
principalTable: "sources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_quotes_users_IdUsersPropose",
column: x => x.IdUsersPropose,
principalTable: "users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "comments",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
IdUser = table.Column<int>(type: "INTEGER", nullable: false),
IdQuote = table.Column<int>(type: "INTEGER", nullable: false),
DateCommentary = table.Column<DateTime>(type: "date", nullable: false),
Comment = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_comments", x => x.Id);
table.ForeignKey(
name: "FK_comments_quotes_IdQuote",
column: x => x.IdQuote,
principalTable: "quotes",
principalColumn: "Id");
table.ForeignKey(
name: "FK_comments_users_IdUser",
column: x => x.IdUser,
principalTable: "users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "favorites",
columns: table => new
{
IdUsers = table.Column<int>(type: "INTEGER", nullable: false),
IdQuote = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_favorites", x => new { x.IdQuote, x.IdUsers });
table.ForeignKey(
name: "FK_favorites_quotes_IdQuote",
column: x => x.IdQuote,
principalTable: "quotes",
principalColumn: "Id");
table.ForeignKey(
name: "FK_favorites_users_IdUsers",
column: x => x.IdUsers,
principalTable: "users",
principalColumn: "Id");
});
migrationBuilder.InsertData(
table: "images",
columns: new[] { "Id", "ImgPath" },
values: new object[,]
{
{ 1, "https://th.bing.com/th/id/OIP.TJuWNCsibz8MVmhdNQEdMwHaE8?w=244&h=180&c=7&r=0&o=5&pid=1.7" },
{ 2, "https://th.bing.com/th/id/OIP.NgXRQ5-IknA6_qOPFhLWIwHaHK?w=165&h=180&c=7&r=0&o=5&pid=1.7" },
{ 3, "https://th.bing.com/th/id/OIP.XcJoJ6bC9sAMjol1pJn5UQHaLH?w=118&h=180&c=7&r=0&o=5&pid=1.7" },
{ 4, "https://th.bing.com/th/id/OIP.PPIESqZaNDa-qUcfSDXhdQHaGK?w=210&h=180&c=7&r=0&o=5&pid=1.7" },
{ 5, "https://th.bing.com/th/id/OIP.XBghSl2kfRNNtQoSxc901wHaHa?w=177&h=180&c=7&r=0&o=5&pid=1.7" },
{ 6, "https://th.bing.com/th/id/OIP.af1Aid64cqEKoIOBgCPxtQHaJO?w=145&h=182&c=7&r=0&o=5&pid=1.7" },
{ 7, "https://th.bing.com/th/id/OIP.ri5vSXr5lNTLt4DO6KQXyQHaI4?w=158&h=189&c=7&r=0&o=5&pid=1.7" },
{ 8, "https://th.bing.com/th/id/OIP.uPTRLR8uspCiafiunUqKfQHaMJ?w=115&h=180&c=7&r=0&o=5&pid=1.7" },
{ 9, "https://th.bing.com/th/id/OIP.hcJis4rKbyQtugsoFJU2ngHaM_?w=118&h=207&c=7&r=0&o=5&pid=1.7" },
{ 10, "https://th.bing.com/th/id/OIP.Py1_XfUrKJY_A6tYEmFS5wHaE8?w=280&h=187&c=7&r=0&o=5&pid=1.7" }
});
migrationBuilder.InsertData(
table: "question",
columns: new[] { "Id", "AnswerA", "AnswerB", "AnswerC", "AnswerD", "CorrectAnswer", "IsValid", "Text" },
values: new object[,]
{
{ 1, "Gimli", "Aragorn", "Frodon", "Gandalf", "B", true, "Qui est le leader de la Communauté de l'Anneau ?" },
{ 2, "Serdaigle", "Gryffondor", "Serpentard", "Poufsouffle", "B", false, "Dans quelle maison Harry Potter est-il ?" },
{ 3, "Saroumane", "Sauron", "Gollum", "Gothmog", "B", true, "Qui est le Seigneur des Ténèbres dans la saga Le Seigneur des Anneaux ?" },
{ 4, "Han Solo", "Princesse Leia", "Chewbacca", "R2-D2", "A", true, "Dans le film Star Wars : Episode IV, qui sauve Luke Skywalker de l'Étoile de la Mort ?" },
{ 5, "Reine Jadis", "Aslan", "Edmund", "Lucy", "B", true, "Qui est le souverain de Narnia dans Le Lion, la Sorcière Blanche et l'Armoire Magique ?" },
{ 6, "Smaug", "Falkor", "Norbert", "Shenron", "A", true, "Quel est le nom du dragon dans Le Hobbit ?" },
{ 7, "Bella Swan", "Edward Cullen", "Jacob Black", "Victoria", "A", true, "Qui est la première personne à être mordue par un vampire dans Twilight ?" },
{ 8, "Obi-Wan Kenobi", "Yoda", "Han Solo", "Luke Skywalker", "A", true, "Quel personnage dit Que la Force soit avec toi dans Star Wars ?" },
{ 9, "Dr. Ellie Sattler", "Alan Grant", "John Hammond", "Dennis Nedry", "B", true, "Dans Jurassic Park, quel est le nom du paléontologue sur l'île ?" },
{ 10, "Cersei Lannister", "Arya Stark", "Daenerys Targaryen", "Sansa Stark", "C", true, "Dans Game of Thrones, qui est surnommée la Mère des Dragons ?" }
});
migrationBuilder.InsertData(
table: "sources",
columns: new[] { "Id", "Title", "TypeSrc", "Year" },
values: new object[,]
{
{ 1, "Jurassic Park", 0, 1993 },
{ 2, "Le Seigneur des anneaux : La Communauté de l'anneau", 0, 2001 },
{ 3, "Game of throne", 1, 2011 },
{ 4, "Harry Potter à l'école des sorcier", 0, 1997 },
{ 5, "Star Wars, épisode IV : Un nouvel espoir", 0, 1977 }
});
migrationBuilder.InsertData(
table: "characters",
columns: new[] { "Id", "IdImage", "Name" },
values: new object[,]
{
{ 1, 1, "Alan Grant" },
{ 2, 2, "Aragorn" },
{ 3, 3, "Legolas" },
{ 4, 4, "Frodon" },
{ 5, 5, "Dobby" },
{ 6, 6, "Jon Snow" },
{ 7, 7, "Daenerys Targaryen" },
{ 8, 8, "Luke Skywalker" },
{ 9, 9, "Princess Leia" },
{ 10, 10, "Harry Potter" }
});
migrationBuilder.InsertData(
table: "quizzes",
columns: new[] { "Id", "IdImage", "NbQuestion", "Title" },
values: new object[,]
{
{ 1, 1, 5, "Quiz 1" },
{ 2, 2, 5, "Quiz 2" }
});
migrationBuilder.InsertData(
table: "users",
columns: new[] { "Id", "Created", "Email", "IdImage", "Password", "UserName" },
values: new object[,]
{
{ 1, new DateTime(2025, 5, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), "jhonDhoe@gmail.com", 1, "1234", "Jhon-Dhoe" },
{ 2, new DateTime(2025, 3, 19, 0, 0, 0, 0, DateTimeKind.Unspecified), "lucy_rose@outlook.com", 2, "abcd", "Lucy-Rose" },
{ 3, new DateTime(2024, 11, 2, 0, 0, 0, 0, DateTimeKind.Unspecified), "mark.taylor@yahoo.com", 3, "5678", "Mark-Taylor" },
{ 4, new DateTime(2025, 2, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), "sophie.martin@gmail.com", 4, "4321", "Sophie-Martin" },
{ 5, new DateTime(2025, 1, 15, 0, 0, 0, 0, DateTimeKind.Unspecified), "nathan_doe@aol.com", 5, "8765", "Nathan-Doe" },
{ 6, new DateTime(2025, 4, 7, 0, 0, 0, 0, DateTimeKind.Unspecified), "ella.brown@icloud.com", 6, "2468", "Ella-Brown" },
{ 7, new DateTime(2024, 12, 25, 0, 0, 0, 0, DateTimeKind.Unspecified), "oliver_smith@gmail.com", 7, "1357", "Oliver-Smith" },
{ 8, new DateTime(2025, 3, 5, 0, 0, 0, 0, DateTimeKind.Unspecified), "mia.jones@outlook.com", 8, "1122", "Mia-Jones" },
{ 9, new DateTime(2025, 2, 22, 0, 0, 0, 0, DateTimeKind.Unspecified), "kevin_williams@aol.com", 9, "2233", "Kevin-Williams" },
{ 10, new DateTime(2025, 1, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), "olivia.white@yahoo.com", 10, "3344", "Olivia-White" }
});
migrationBuilder.InsertData(
table: "QuizQuestion",
columns: new[] { "IdQuestion", "IdQuiz" },
values: new object[,]
{
{ 1, 1 },
{ 2, 1 },
{ 3, 1 },
{ 4, 1 },
{ 5, 1 },
{ 6, 2 },
{ 7, 2 },
{ 8, 2 },
{ 9, 2 },
{ 10, 2 }
});
migrationBuilder.InsertData(
table: "quotes",
columns: new[] { "Id", "Content", "IdCharacter", "IdSource", "IdUsersPropose", "IsValid", "Langage", "Likes" },
values: new object[,]
{
{ 1, "Je n'y crois pas. Je n'y crois pas. Ce n'est pas possible", 1, 1, 1, true, 1, 11025 },
{ 2, "There is always hope", 2, 2, 1, true, 0, 11025 },
{ 3, "A red sun rises. Blood has been spilled this night.", 3, 2, 1, true, 0, 11025 },
{ 4, "I wish the Ring had never come to me.I wish none of this had happened.", 4, 2, 1, true, 0, 11025 },
{ 5, "Dobby is a free elf!", 5, 4, 1, true, 0, 11025 },
{ 6, "Winter is comming", 6, 3, 1, true, 0, 11025 },
{ 7, "Je suis la dernière Targaryen. Je suis la reine des dragons", 7, 3, 1, true, 1, 11025 },
{ 8, "Je ne suis pas prêt à affronter ça. C'est trop pour moi.", 8, 5, 1, true, 1, 11025 },
{ 9, "Aidez-moi, Obi-Wan Kenobi, vous êtes mon seul espoir.", 9, 5, 1, true, 1, 11025 },
{ 10, "La quoi ?", 10, 4, 1, false, 1, 11025 }
});
migrationBuilder.InsertData(
table: "comments",
columns: new[] { "Id", "Comment", "DateCommentary", "IdQuote", "IdUser" },
values: new object[,]
{
{ 1, "Ce film est le meilleur", new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, 2 },
{ 2, "Very good", new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, 3 }
});
migrationBuilder.InsertData(
table: "favorites",
columns: new[] { "IdQuote", "IdUsers" },
values: new object[,]
{
{ 1, 6 },
{ 2, 8 },
{ 3, 2 },
{ 4, 10 },
{ 5, 3 },
{ 6, 7 },
{ 8, 9 },
{ 9, 1 },
{ 10, 5 }
});
migrationBuilder.CreateIndex(
name: "IX_admins_UserId",
table: "admins",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_characters_IdImage",
table: "characters",
column: "IdImage");
migrationBuilder.CreateIndex(
name: "IX_comments_IdQuote",
table: "comments",
column: "IdQuote");
migrationBuilder.CreateIndex(
name: "IX_comments_IdUser",
table: "comments",
column: "IdUser");
migrationBuilder.CreateIndex(
name: "IX_favorites_IdUsers",
table: "favorites",
column: "IdUsers");
migrationBuilder.CreateIndex(
name: "IX_QuizQuestion_IdQuiz",
table: "QuizQuestion",
column: "IdQuiz");
migrationBuilder.CreateIndex(
name: "IX_quizzes_IdImage",
table: "quizzes",
column: "IdImage");
migrationBuilder.CreateIndex(
name: "IX_quotes_IdCharacter",
table: "quotes",
column: "IdCharacter");
migrationBuilder.CreateIndex(
name: "IX_quotes_IdSource",
table: "quotes",
column: "IdSource");
migrationBuilder.CreateIndex(
name: "IX_quotes_IdUsersPropose",
table: "quotes",
column: "IdUsersPropose");
migrationBuilder.CreateIndex(
name: "IX_users_IdImage",
table: "users",
column: "IdImage");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "admins");
migrationBuilder.DropTable(
name: "comments");
migrationBuilder.DropTable(
name: "favorites");
migrationBuilder.DropTable(
name: "QuizQuestion");
migrationBuilder.DropTable(
name: "quotes");
migrationBuilder.DropTable(
name: "question");
migrationBuilder.DropTable(
name: "quizzes");
migrationBuilder.DropTable(
name: "characters");
migrationBuilder.DropTable(
name: "sources");
migrationBuilder.DropTable(
name: "users");
migrationBuilder.DropTable(
name: "images");
}
}
}

@ -7,7 +7,8 @@ using Contextlib;
using Entity; using Entity;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Npgsql.EntityFrameworkCore.PostgreSQL;
namespace StubbedContextLib namespace StubbedContextLib
{ {

Loading…
Cancel
Save