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.

75 lines
2.2 KiB

3 years ago
  1. CREATE TABLE IF NOT EXISTS auth.users (
  2. id SERIAL PRIMARY KEY,
  3. username VARCHAR(255) UNIQUE NOT NULL,
  4. password VARCHAR(255) NOT NULL,
  5. email VARCHAR(255) UNIQUE NOT NULL,
  6. firstname VARCHAR(100) NULL,
  7. surname VARCHAR(100) NULL,
  8. avatar VARCHAR(100) NULL,
  9. active INT NOT NULL
  10. );
  11. CREATE TABLE IF NOT EXISTS auth.forgotpassword_keys (
  12. id SERIAL PRIMARY KEY,
  13. email VARCHAR(255) NOT NULL,
  14. key VARCHAR(4) NOT NULL,
  15. created_at TIMESTAMP DEFAULT NOW()
  16. );
  17. CREATE TABLE IF NOT EXISTS auth.forgotpassword_questions (
  18. id SERIAL PRIMARY KEY,
  19. question VARCHAR(255) NOT NULL,
  20. active INT NOT NULL
  21. );
  22. CREATE TABLE IF NOT EXISTS auth.forgotpassword_questions_users_answers (
  23. id SERIAL PRIMARY KEY,
  24. forgotpassword_questions_id INT NOT NULL,
  25. users_id INT NOT NULL,
  26. answer VARCHAR(255) NOT NULL,
  27. FOREIGN KEY (forgotpassword_questions_id) REFERENCES auth.forgotpassword_questions (id),
  28. FOREIGN KEY (users_id) REFERENCES auth.users (id)
  29. );
  30. CREATE TABLE IF NOT EXISTS auth.roles (
  31. id SERIAL PRIMARY KEY,
  32. name VARCHAR(100) NOT NULL,
  33. active INT NOT NULL
  34. );
  35. CREATE TABLE IF NOT EXISTS auth.users_roles (
  36. users_id INT NOT NULL,
  37. roles INT NOT NULL,
  38. FOREIGN KEY (users_id) REFERENCES auth.users (id)
  39. );
  40. CREATE TABLE IF NOT EXISTS auth.users_rolesprovider_activationkey (
  41. id SERIAL PRIMARY KEY,
  42. users_id INT NOT NULL,
  43. roles_id INT NOT NULL,
  44. activationkey uuid NOT NULL,
  45. FOREIGN KEY (users_id) REFERENCES auth.users (id),
  46. FOREIGN KEY (roles_id) REFERENCES auth.roles (id)
  47. );
  48. CREATE TABLE IF NOT EXISTS auth.educemaden_organizations (
  49. id INT NOT NULL,
  50. active VARCHAR(20) NULL,
  51. name VARCHAR(255) NOT NULL,
  52. creation_date varchar(50) NULL,
  53. inep_code varchar(100) NULL,
  54. phone varchar(100) NOT NULL,
  55. type varchar(100) NULL,
  56. website varchar(255) NULL,
  57. login varchar(50) NULL,
  58. address varchar(50) NULL,
  59. responsible varchar(50) NULL
  60. );
  61. CREATE TABLE IF NOT EXISTS auth.users_educemaden_organizations (
  62. id SERIAL PRIMARY KEY,
  63. users_id INT NOT NULL,
  64. educemaden_organizations_id INT NOT NULL,
  65. activationkey uuid NOT NULL,
  66. FOREIGN KEY (users_id) REFERENCES auth.users (id)
  67. );