   "path" text
 );
 
+DROP TABLE IF EXISTS "playlist";
 CREATE TABLE "playlist" (
   "id" serial PRIMARY KEY,
   "name" text NOT NULL,
-  "user_id" integer REFERENCES "user" ("id"),
+  "user_id" integer,
   "order" integer[]
 );
 
+ALTER TABLE "user"
+  ADD CONSTRAINT "active_playlist_id" REFERENCES "playlist" ("id");
+ALTER TABLE "playlist"
+  ADD CONSTRAINT "user_id" REFERENCES "user" ("id");
+
+DROP TABLE IF EXISTS "playlist_has_song";
 CREATE TABLE "playlist_has_song" (
   "playlist_id" integer REFERENCES "playlist" ("id"),
   "song_id" integer REFERENCES "song" ("id")
 );
 
-
+DROP TABLE IF EXISTS "session";
 CREATE TABLE "session" (
   "sid" varchar NOT NULL COLLATE "default",
   "sess" json NOT NULL,

  OIDS=FALSE
);

CREATE TABLE "user" (
  "id" serial PRIMARY KEY,
  "username" text NOT NULL,
  "hash" text,
  "password_change_request_hash" text,
  "active_playlist_id" integer REFERENCES "playlist" ("id")
);

CREATE TABLE "song" (
  "id" serial PRIMARY KEY,
  "plugId" integer,


SELECT pg_catalog.setval('playlist_id_seq', 1, true);

SELECT pg_catalog.setval('song_id_seq', 5, true);

SELECT pg_catalog.setval('user_id_seq', 1, true);
