Advertisement
Guest User

Untitled

a guest
Sep 10th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. class User(db.Model, UserMixin):
  2. __tablename__ = "users"
  3.  
  4. id = db.Column(db.Integer, primary_key=True)
  5.  
  6. username = db.Column(db.String(64), nullable=False, unique=True)
  7. password = db.Column(db.String(255), nullable=False, server_default="")
  8.  
  9. email = db.Column(db.String(254), nullable=False, unique=True)
  10. confirmed_at = db.Column(db.DateTime())
  11.  
  12. is_enabled = db.Column(db.Boolean(), nullable=False, default=False)
  13.  
  14. def is_active(self):
  15. return self.is_enabled
  16.  
  17. CREATE TABLE users (
  18. id INTEGER NOT NULL AUTO_INCREMENT,
  19. username VARCHAR(64) NOT NULL,
  20. password VARCHAR(255) NOT NULL DEFAULT '',
  21. email VARCHAR(254) NOT NULL,
  22. confirmed_at DATETIME,
  23. is_enabled BOOL NOT NULL,
  24. PRIMARY KEY (id),
  25. UNIQUE (username),
  26. UNIQUE (email),
  27. CHECK (is_enabled IN (0, 1))
  28. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement