Ei kuvausta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

etc_opendmarc_import.sql 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # Source: http://www.trusteddomain.org/pipermail/opendmarc-users/2015-February/000447.html
  2. START TRANSACTION;
  3. SET standard_conforming_strings=off;
  4. SET escape_string_warning=off;
  5. SET CONSTRAINTS ALL DEFERRED;
  6. CREATE TABLE "domains" (
  7. "id" integer NOT NULL,
  8. "name" varchar(510) NOT NULL,
  9. "firstseen" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  10. PRIMARY KEY ("id"),
  11. UNIQUE ("name")
  12. );
  13. CREATE TABLE "ipaddr" (
  14. "id" integer NOT NULL,
  15. "addr" varchar(128) NOT NULL,
  16. "firstseen" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  17. PRIMARY KEY ("id"),
  18. UNIQUE ("addr")
  19. );
  20. CREATE TABLE "messages" (
  21. "id" integer NOT NULL,
  22. "date" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  23. "jobid" varchar(256) NOT NULL,
  24. "reporter" integer NOT NULL,
  25. "policy" tinyint(3) NOT NULL,
  26. "disp" tinyint(3) NOT NULL,
  27. "ip" integer NOT NULL,
  28. "env_domain" integer NOT NULL,
  29. "from_domain" integer NOT NULL,
  30. "policy_domain" integer NOT NULL,
  31. "spf" tinyint(3) NOT NULL,
  32. "align_dkim" tinyint(3) NOT NULL,
  33. "align_spf" tinyint(3) NOT NULL,
  34. "sigcount" tinyint(3) NOT NULL,
  35. PRIMARY KEY ("id"),
  36. UNIQUE ("reporter", "date", "jobid")
  37. );
  38. CREATE TABLE "reporters" (
  39. "id" integer NOT NULL,
  40. "name" varchar(510) NOT NULL,
  41. "firstseen" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  42. PRIMARY KEY ("id"),
  43. UNIQUE ("name")
  44. );
  45. CREATE TABLE "requests" (
  46. "id" integer NOT NULL,
  47. "domain" integer NOT NULL,
  48. "repuri" varchar(510) NOT NULL,
  49. "adkim" tinyint(4) NOT NULL,
  50. "aspf" tinyint(4) NOT NULL,
  51. "policy" tinyint(4) NOT NULL,
  52. "spolicy" tinyint(4) NOT NULL,
  53. "pct" tinyint(4) NOT NULL,
  54. "locked" tinyint(4) NOT NULL,
  55. "firstseen" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  56. "lastsent" timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  57. PRIMARY KEY ("id"),
  58. UNIQUE ("domain")
  59. );
  60. CREATE TABLE "signatures" (
  61. "id" integer NOT NULL,
  62. "message" integer NOT NULL,
  63. "domain" integer NOT NULL,
  64. "pass" tinyint(4) NOT NULL,
  65. "error" tinyint(4) NOT NULL,
  66. PRIMARY KEY ("id")
  67. );
  68. COMMIT;
  69. -- Sequences --
  70. START TRANSACTION;
  71. CREATE SEQUENCE domains_id_seq;
  72. SELECT setval('domains_id_seq', max(id)) FROM domains;
  73. ALTER TABLE "domains" ALTER COLUMN "id" SET DEFAULT nextval('domains_id_seq');
  74. CREATE SEQUENCE ipaddr_id_seq;
  75. SELECT setval('ipaddr_id_seq', max(id)) FROM ipaddr;
  76. ALTER TABLE "ipaddr" ALTER COLUMN "id" SET DEFAULT nextval('ipaddr_id_seq');
  77. CREATE SEQUENCE messages_id_seq;
  78. SELECT setval('messages_id_seq', max(id)) FROM messages;
  79. ALTER TABLE "messages" ALTER COLUMN "id" SET DEFAULT nextval('messages_id_seq');
  80. CREATE SEQUENCE reporters_id_seq;
  81. SELECT setval('reporters_id_seq', max(id)) FROM reporters;
  82. ALTER TABLE "reporters" ALTER COLUMN "id" SET DEFAULT nextval('reporters_id_seq');
  83. CREATE SEQUENCE requests_id_seq;
  84. SELECT setval('requests_id_seq', max(id)) FROM requests;
  85. ALTER TABLE "requests" ALTER COLUMN "id" SET DEFAULT nextval('requests_id_seq');
  86. CREATE SEQUENCE signatures_id_seq;
  87. SELECT setval('signatures_id_seq', max(id)) FROM signatures;
  88. ALTER TABLE "signatures" ALTER COLUMN "id" SET DEFAULT nextval('signatures_id_seq');
  89. COMMIT;