Commit b7916759 authored by Hugo Hörnquist's avatar Hugo Hörnquist
Browse files

updated database

parent bf095068
INSERT INTO domain (name, uid)
values ("hornquist.se", 2278);
INSERT INTO domain (name, personid)
SELECT "porr", id FROM person WHERE username = "jiffe";
INSERT INTO domain (name, personid)
SELECT "jiffe.se", id FROM person WHERE username = "jiffe";
-- keys here?
INSERT INTO subdomain (name, domainid)
SELECT "@", id FROM domain
WHERE name = "hornquist.se" AND personid = (SELECT id FROM person WHERE username = "hugo");
-- TODO why?
delimiter // delimiter //
DROP TABLE IF EXISTS dkeys;//
DROP TABLE IF EXISTS subdomain;// DROP TABLE IF EXISTS subdomain;//
DROP TABLE IF EXISTS domain;// DROP TABLE IF EXISTS update_key;//
DROP TABLE IF EXISTS person;//
DROP TABLE IF EXISTS record_types;// DROP TABLE IF EXISTS record_types;//
DROP TABLE IF EXISTS domain;//
create table person -- This table is used as an enum table
CREATE TABLE record_types
( (
id int(11) NOT NULL AUTO_INCREMENT, id int(11) NOT NULL AUTO_INCREMENT,
name varchar(255), name varchar (16) NOT NULL,
username varchar(255),
CONSTRAINT pk_person_id PRIMARY KEY (id) CONSTRAINT pk_record_types_id PRIMARY KEY (id),
CONSTRAINT uc_record_types_name UNIQUE (name)
)ENGINE=InnoDB;// )ENGINE=InnoDB;//
create table domain CREATE TABLE domain
( (
id int(11) NOT NULL AUTO_INCREMENT, id int(11) NOT NULL AUTO_INCREMENT,
name varchar(255), name varchar(191), -- hornquist.se
personid int(11), uid int(11), -- 2278
CONSTRAINT pk_domain_id PRIMARY KEY (id), CONSTRAINT pk_domain_id PRIMARY KEY (id),
CONSTRAINT fk_domain_perid FOREIGN KEY (personid) REFERENCES person(id) CONSTRAINT uc_domain_name UNIQUE (name)
)ENGINE=InnoDB;// )ENGINE=InnoDB;//
create table subdomain CREATE TABLE subdomain
( (
id int(11) NOT NULL AUTO_INCREMENT, id int(11) NOT NULL AUTO_INCREMENT,
name varchar(255), name varchar(191) NOT NULL, -- blog, `@' for no subdomain
ttl int(11) DEFAULT 86400 NOT NULL, ttl int(11) DEFAULT 600 NOT NULL,
class varchar(255) default "IN" NOT NULL, class varchar(255) DEFAULT "IN" NOT NULL,
-- rr varchar(255) default "A" NOT NULL, rr int(11) NOT NULL, -- A, MX
rr int(11) NOT NULL,
destination varchar(255), -- only for cname destination varchar(255), -- only for cname
domainid int(11), domainid int(11),
CONSTRAINT pk_subdomain_id PRIMARY KEY (id), CONSTRAINT pk_subdomain_id PRIMARY KEY (id),
CONSTRAINT fk_subdomain_domid FOREIGN KEY (domainid) REFERENCES domain(id) CONSTRAINT fk_subdomain_domid FOREIGN KEY (domainid) REFERENCES domain(id),
CONSTRAINT fk_subdomain_rr FOREIGN KEY (rr) REFERENCES record_types (id),
CONSTRAINT uc_subdomain_name_domainid UNIQUE (name, domainid)
)ENGINE=InnoDB;// )ENGINE=InnoDB;//
-- dkey really should be key, but that's a reserver SQL keyword CREATE TABLE update_key
create table dkeys
( (
id int(11) NOT NULL AUTO_INCREMENT, id int(11) NOT NULL AUTO_INCREMENT,
domainid int(11), domainid int(11) NOT NULL,
dkey varchar(255),
secret varchar(255),
CONSTRAINT pk_dkeys_id PRIMARY KEY (id), update_key varchar(255) NOT NULL,
CONSTRAINT fk_dkeys_domid FOREIGN KEY (domainid) REFERENCES domain(id) secret varchar(255) NOT NULL,
)ENGINE=InnoDB;// CONSTRAINT pk_update_key_id PRIMARY KEY (id),
CONSTRAINT fk_update_key_domid FOREIGN KEY (domainid) REFERENCES domain(id)
-- This table is used as an enum table
CREATE TABLE record_types
(
id int(11) NOT NULL AUTO_INCREMENT,
name varchar (16) NOT NULL,
CONSTRAINT pk_record_types_id PRIMARY KEY (id),
CONSTRAINT uc_record_types_name UNIQUE (name)
)ENGINE=InnoDB;// )ENGINE=InnoDB;//
-- Insert intial values.
-- Should probably be moved somewhere else
-- INSERT INTO record_types (name) VALUES ("A"), ("AAAA");
DELETE FROM subdomain;
DELETE FROM record_types;
DELETE FROM domain;
INSERT INTO domain (id, uid, name)
VALUES (1, 2278, "hornquist.se"),
(2, 2278, "hugoweb.ga"),
(3, 2116, "jiffe.jiff");
INSERT INTO record_types (id, name)
VALUES (1, "A"),
(2, "AAAA"),
(3, "CNAME"),
(4, "TXT");
INSERT INTO subdomain (id, domainid, name, rr, ttl)
VALUES (1, 1, "@", 1, 300),
(2, 2, "www", 1, 300),
(3, 1, "blog", 1, 300),
(4, 3, "jeff", 1, 86400);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment