1
0

AuthStore.migrations 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. :VERSION 1
  2. BEGIN TRANSACTION;
  3. CREATE TABLE auth (
  4. uuid uuid NOT NULL default '00000000-0000-0000-0000-000000000000',
  5. "passwordHash" varchar(32) NOT NULL,
  6. "passwordSalt" varchar(32) NOT NULL,
  7. "webLoginKey" varchar(255) NOT NULL,
  8. "accountType" VARCHAR(32) NOT NULL DEFAULT 'UserAccount'
  9. ) ;
  10. CREATE TABLE tokens (
  11. uuid uuid NOT NULL default '00000000-0000-0000-0000-000000000000',
  12. token varchar(255) NOT NULL,
  13. validity TIMESTAMP NOT NULL )
  14. ;
  15. COMMIT;
  16. :VERSION 2
  17. BEGIN TRANSACTION;
  18. INSERT INTO auth (uuid, "passwordHash", "passwordSalt", "webLoginKey", "accountType")
  19. SELECT uuid AS UUID, passwordHash AS passwordHash, passwordSalt AS passwordSalt, webLoginKey AS webLoginKey, 'UserAccount' as accountType
  20. FROM users
  21. where exists ( Select * from information_schema.tables where table_name = 'users' )
  22. ;
  23. COMMIT;
  24. :VERSION 3
  25. BEGIN TRANSACTION;
  26. CREATE UNIQUE INDEX auth_pkey ON auth USING btree (uuid);
  27. ALTER TABLE tokens ADD CONSTRAINT "uuid_token" UNIQUE ("uuid","token") NOT DEFERRABLE INITIALLY IMMEDIATE;
  28. COMMIT;