/blogmaker/blog/migrations/sql/init.sql

http://blogmaker.googlecode.com/ · SQL · 52 lines · 52 code · 0 blank · 0 comment · 0 complexity · 39dca32aa9777d5d0133e53c77d67343 MD5 · raw file

  1. BEGIN;
  2. CREATE TABLE "blog_entry" (
  3. "id" serial NOT NULL PRIMARY KEY,
  4. "pub_date" timestamp with time zone NOT NULL,
  5. "slug" varchar(120) NOT NULL,
  6. "headline" varchar(255) NOT NULL,
  7. "summary" varchar(255) NULL,
  8. "image" varchar(100) NULL,
  9. "copyright" varchar(255) NULL,
  10. "body" text NOT NULL,
  11. "active" boolean NOT NULL,
  12. "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED,
  13. "externalId" integer NULL
  14. );
  15. CREATE TABLE "blog_tag" (
  16. "id" serial NOT NULL PRIMARY KEY,
  17. "tag" varchar(255) NOT NULL UNIQUE,
  18. "slug" varchar(120) NOT NULL UNIQUE
  19. );
  20. CREATE TABLE "blog_pingurl" (
  21. "id" serial NOT NULL PRIMARY KEY,
  22. "ping_url" varchar(200) NOT NULL,
  23. "blog_url" varchar(200) NOT NULL,
  24. "blog_name" varchar(200) NOT NULL
  25. );
  26. CREATE TABLE "blog_trackbackstatus" (
  27. "id" serial NOT NULL PRIMARY KEY,
  28. "entry_id" integer NOT NULL REFERENCES "blog_entry" ("id") DEFERRABLE INITIALLY DEFERRED,
  29. "link" varchar(300) NOT NULL,
  30. "trackbackUrl" varchar(200) NOT NULL,
  31. "attempted" timestamp with time zone NULL,
  32. "status" varchar(10) NOT NULL,
  33. "message" text NOT NULL
  34. );
  35. CREATE TABLE "blog_entry_tags" (
  36. "id" serial NOT NULL PRIMARY KEY,
  37. "entry_id" integer NOT NULL REFERENCES "blog_entry" ("id") DEFERRABLE INITIALLY DEFERRED,
  38. "tag_id" integer NOT NULL REFERENCES "blog_tag" ("id") DEFERRABLE INITIALLY DEFERRED,
  39. UNIQUE ("entry_id", "tag_id")
  40. );
  41. CREATE TABLE "blog_entry_related_entries" (
  42. "id" serial NOT NULL PRIMARY KEY,
  43. "from_entry_id" integer NOT NULL REFERENCES "blog_entry" ("id") DEFERRABLE INITIALLY DEFERRED,
  44. "to_entry_id" integer NOT NULL REFERENCES "blog_entry" ("id") DEFERRABLE INITIALLY DEFERRED,
  45. UNIQUE ("from_entry_id", "to_entry_id")
  46. );
  47. CREATE INDEX blog_entry_pub_date ON "blog_entry" ("pub_date");
  48. CREATE INDEX blog_entry_slug ON "blog_entry" ("slug");
  49. CREATE INDEX blog_entry_user_id ON "blog_entry" ("user_id");
  50. CREATE UNIQUE INDEX blog_tag_slug ON "blog_tag" ("slug");
  51. CREATE INDEX blog_trackbackstatus_entry_id ON "blog_trackbackstatus" ("entry_id");
  52. COMMIT;