Last active
December 22, 2015 18:59
-
-
Save sivy/6516883 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE user_accounts ( | |
id VARCHAR(25) NOT NULL, | |
-- ... snip | |
PRIMARY KEY (id), | |
) | |
CREATE TABLE user_blogsettings ( | |
id INTEGER NOT NULL AUTO_INCREMENT, | |
user_id VARCHAR(128), | |
-- ... snip | |
PRIMARY KEY (id), | |
FOREIGN KEY(user_id) REFERENCES user_accounts (id) ON DELETE CASCADE | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User(ModelBase, AuthUser): | |
""" | |
Implementation of User for persistence in Google's App Engine datastore. | |
""" | |
__tablename__ = 'user_accounts' | |
__public__ = ['uid', 'name', 'email', 'irc', 'phone', 'tz'] | |
id = sa.Column(sa.String(25), primary_key=True) | |
# ... snip | |
blog = relationship('models.UserBlogSettings', uselist=False, | |
backref='user', cascade="all, delete-orphan", | |
passive_deletes=True) | |
class UserBlogSettings(ModelBase): | |
__tablename__ = 'user_blogsettings' | |
id = sa.Column(sa.Integer, primary_key=True) | |
user_id = sa.Column(sa.String(128), | |
sa.ForeignKey('user_accounts.id', ondelete='CASCADE')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment