migration_7.py 579 B

1234567891011121314151617181920212223
  1. # Migration to add user_spaces table
  2. from datetime import datetime
  3. def migration(conn):
  4. with conn.cursor() as cursor:
  5. cursor.execute(
  6. """
  7. CREATE TABLE user_spaces (
  8. space_id TEXT NOT NULL,
  9. user_id TEXT NOT NULL,
  10. active BOOLEAN NOT NULL DEFAULT TRUE,
  11. PRIMARY KEY (space_id, user_id)
  12. )
  13. """
  14. )
  15. cursor.execute(
  16. "INSERT INTO migrations (id, timestamp) VALUES (7, ?)",
  17. (datetime.now(),)
  18. )
  19. conn.commit()