
---- 29/04/2022

CREATE DATABASE db_nostalgia;

DROP TABLE users;

CREATE TABLE IF NOT exists users( 
        id int not null primary key auto_increment, 
        name varchar(500), 
        nameGroup varchar(500), 
        email varchar(255),
        phone varchar(20),
        password varchar(500), 
        typeUser varchar(20), 
        status int,
        tokenFirebase varchar(500), 
        codeVersion varchar(10),
        createdAt timestamp NULL DEFAULT CURRENT_TIMESTAMP, 
        updatedAt datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
 );

DROP TABLE address;

 CREATE TABLE IF NOT exists address( 
        id int not null primary key auto_increment,
        idUser int,
        street varchar(255),
        number varchar(20),
        neighborhood varchar(255),
        city varchar(300),
        state varchar(20),
        zipeCode varchar(11),
        stateAbbreviation varchar(10),
        createdAt timestamp NULL DEFAULT CURRENT_TIMESTAMP, 
        updatedAt datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
       FOREIGN KEY (idUser) REFERENCES users (id)
 );

  CREATE TABLE IF NOT exists publications( 
        id int not null primary key auto_increment,
        idUser int,
        url varchar(500),
        title varchar(500),
        data varchar(30),
        status int,
        createdAt timestamp NULL DEFAULT CURRENT_TIMESTAMP, 
        updatedAt datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
       FOREIGN KEY (idUser) REFERENCES users (id)
 );

