igormieski27 / MyPathBackend

Aplicação do conceito de gamificação em desenvolvimento pessoal desenvolvido com Vue.js e Laravel.
1 stars 0 forks source link

SQL #5

Open igormieski27 opened 1 year ago

igormieski27 commented 1 year ago
-- Table: public.habitos

-- DROP TABLE IF EXISTS public.habitos;

CREATE TABLE IF NOT EXISTS public.habitos
(
    id integer NOT NULL DEFAULT nextval('migrations_id_seq'::regclass),
    id_usuario integer NOT NULL,
    title character varying(30) COLLATE pg_catalog."default" NOT NULL,
    icon character varying(80) COLLATE pg_catalog."default" NOT NULL,
    color character varying(30) COLLATE pg_catalog."default" NOT NULL,
    value boolean NOT NULL DEFAULT false,
    period integer,
    days json,
    CONSTRAINT "pkHabitos" PRIMARY KEY (id),
    CONSTRAINT "fkHabitosUsuarios" FOREIGN KEY (id_usuario)
        REFERENCES public.usuarios (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE CASCADE
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.habitos
    OWNER to postgres;
igormieski27 commented 1 year ago
-- Table: public.items

-- DROP TABLE IF EXISTS public.items;

CREATE TABLE IF NOT EXISTS public.items
(
    id integer NOT NULL DEFAULT nextval('items_id_seq'::regclass),
    nome character varying(75) COLLATE pg_catalog."default" NOT NULL,
    valor integer NOT NULL,
    referencia character varying(75) COLLATE pg_catalog."default" NOT NULL,
    categoria character varying(10) COLLATE pg_catalog."default" NOT NULL,
    CONSTRAINT items_pkey PRIMARY KEY (id)
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.items
    OWNER to postgres;
igormieski27 commented 1 year ago
-- Table: public.tarefas

-- DROP TABLE IF EXISTS public.tarefas;

CREATE TABLE IF NOT EXISTS public.tarefas
(
    id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
    title character varying COLLATE pg_catalog."default" NOT NULL,
    description character varying COLLATE pg_catalog."default" NOT NULL,
    reward_exp integer NOT NULL,
    reward_gold integer NOT NULL,
    id_category integer NOT NULL,
    deadline date NOT NULL,
    CONSTRAINT tarefas_pkey PRIMARY KEY (id)
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.tarefas
    OWNER to postgres;
igormieski27 commented 1 year ago
-- Table: public.usuario_item

-- DROP TABLE IF EXISTS public.usuario_item;

CREATE TABLE IF NOT EXISTS public.usuario_item
(
    id integer NOT NULL DEFAULT nextval('usuario_item_id_seq'::regclass),
    id_usuario integer NOT NULL,
    id_item integer NOT NULL,
    CONSTRAINT usuario_item_pkey PRIMARY KEY (id),
    CONSTRAINT "FK_item" FOREIGN KEY (id_item)
        REFERENCES public.items (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "FK_usuario" FOREIGN KEY (id_usuario)
        REFERENCES public.usuarios (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.usuario_item
    OWNER to postgres;
igormieski27 commented 1 year ago
-- Table: public.usuario_tarefa

-- DROP TABLE IF EXISTS public.usuario_tarefa;

CREATE TABLE IF NOT EXISTS public.usuario_tarefa
(
    id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
    id_usuario integer NOT NULL,
    id_tarefa integer NOT NULL,
    status boolean NOT NULL DEFAULT false,
    data_conclusao date,
    CONSTRAINT usuario_tarefa_pkey PRIMARY KEY (id),
    CONSTRAINT pk_tarefa FOREIGN KEY (id_tarefa)
        REFERENCES public.tarefas (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        NOT VALID,
    CONSTRAINT pk_usuario FOREIGN KEY (id_usuario)
        REFERENCES public.usuarios (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        NOT VALID
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.usuario_tarefa
    OWNER to postgres;
igormieski27 commented 1 year ago
-- Table: public.usuarios

-- DROP TABLE IF EXISTS public.usuarios;

CREATE TABLE IF NOT EXISTS public.usuarios
(
    id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
    nome character varying(128) COLLATE pg_catalog."default" NOT NULL,
    email character varying(128) COLLATE pg_catalog."default" NOT NULL,
    senha character varying(64) COLLATE pg_catalog."default" NOT NULL,
    updated_at timestamp without time zone,
    last_used_at timestamp without time zone,
    created_at timestamp without time zone NOT NULL,
    expires_at timestamp without time zone,
    personagem json NOT NULL DEFAULT '{"charTop": "shirt", "charHair": 1, "charHead": null, "eyeColor": "#23A52E", "bodyColor": "#CA977FDE", "hairColor": "#3f3f3f", "charBottom": "black-pants"}'::jsonb,
    level integer NOT NULL DEFAULT 1,
    xp bigint NOT NULL DEFAULT 0,
    gold bigint NOT NULL DEFAULT 0,
    CONSTRAINT usuarios_pkey PRIMARY KEY (id)
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.usuarios
    OWNER to postgres;