Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace PancakeProwler.Data.Postgres.Repositories
{
public class RecipeRepository : IRecipeRepository
public class RecipeRepository : IRecipeRepository, IPostgresRepository
{
public IEnumerable<Recipe> List()
{
Expand Down Expand Up @@ -39,5 +39,25 @@ public Recipe GetById(Guid id)
private string ConnectionString {
get { return ConfigurationManager.ConnectionStrings["Postgres"].ConnectionString; }
}

public void InitPostgresStorage()
{
var sql = @"DROP TABLE IF EXISTS recipes;
CREATE TABLE recipes
(
""id"" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'::uuid,
""name"" text NOT NULL DEFAULT ''::text,
""contributor"" text,
""ingredients"" text,
""steps"" text,
""image_location"" text,
CONSTRAINT ""pk_recipes"" PRIMARY KEY (""id"")
);";
using ( var conn = new NpgsqlConnection( ConnectionString ) )
{
conn.Open();
conn.Execute(sql);
}
}
}
}