Skip to content

Instantly share code, notes, and snippets.

@sivy
Last active December 22, 2015 18:59
Show Gist options
  • Save sivy/6516883 to your computer and use it in GitHub Desktop.
Save sivy/6516883 to your computer and use it in GitHub Desktop.
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
)
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