# -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 ############################################################################### # ScribeEngine - Open Source Blog Software # # --------------------------------------------------------------------------- # # Copyright (c) 2010 Raoul Snyman # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # # Software Foundation; version 2 of the License. # # # # This program is distributed in the hope that it will be useful, but WITHOUT # # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # # more details. # # # # You should have received a copy of the GNU General Public License along # # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ This module contains the table definitions. """ from datetime import datetime from sqlalchemy import Table, Column, ForeignKey from sqlalchemy.types import Unicode, Integer, UnicodeText, DateTime from scribeengine.model.meta import metadata # Definition of the "categories" table categories_table = Table(u'categories', metadata, Column(u'id', Integer, primary_key=True), Column(u'name', Unicode(100), nullable=False), Column(u'description', UnicodeText), Column(u'url', Unicode(255), nullable=False, index=True, unique=True), ) # Definition of the "comments" table comments_table = Table(u'comments', metadata, Column(u'id', Integer, primary_key=True), Column(u'post_id', Integer, ForeignKey(u'posts.id'), nullable=True), Column(u'user_id', Integer, ForeignKey(u'users.id'), nullable=False), Column(u'title', Unicode(100), nullable=False), Column(u'body', UnicodeText, nullable=False), Column(u'status', Unicode(10), default='moderated'), Column(u'created', DateTime, default=datetime.now()), Column(u'modified', DateTime, default=datetime.now()) ) # Definition of the "pages" table pages_table = Table(u'pages', metadata, Column(u'id', Integer, primary_key=True), Column(u'title', Unicode(255), nullable=False), Column(u'body', UnicodeText), Column(u'url', Unicode(255), nullable=False, index=True, unique=True), Column(u'created', DateTime, default=datetime.now()), Column(u'modified', DateTime, default=datetime.now()) ) # Definition of the "permissions" table permissions_table = Table(u'permissions', metadata, Column(u'id', Integer, primary_key=True), Column(u'name', Unicode(80), nullable=False, index=True), Column(u'description', UnicodeText) ) # Definition of the "posts" table posts_table = Table(u'posts', metadata, Column(u'id', Integer, primary_key=True), Column(u'user_id', Integer, ForeignKey(u'users.id'), nullable=False), Column(u'title', Unicode(255), nullable=False, index=True), Column(u'body', UnicodeText, nullable=False, index=True), Column(u'url', Unicode(255), nullable=False, index=True), Column(u'status', Unicode(10), default=u'draft', index=True), Column(u'comment_status', Unicode(10), default=u'open'), Column(u'created', DateTime, default=datetime.now()), Column(u'modified', DateTime, default=datetime.now()) ) # Definition of the "roles" table roles_table = Table(u'roles', metadata, Column(u'id', Integer, primary_key=True), Column(u'name', Unicode(80), nullable=False, index=True), Column(u'description', UnicodeText) ) # Definition of the "tags" table tags_table = Table(u'tags', metadata, Column(u'id', Integer, primary_key=True), Column(u'name', Unicode(100), nullable=False), Column(u'url', Unicode(255), nullable=False, index=True), ) # Definition of the "users" table users_table = Table(u'users', metadata, Column(u'id', Integer, primary_key=True), Column(u'email', Unicode(200), nullable=False, index=True), Column(u'password', Unicode(64), nullable=False), Column(u'nick', Unicode(50), nullable=False, index=True), Column(u'first_name', Unicode(100), default=u''), Column(u'last_name', Unicode(100), default=u''), Column(u'homepage', Unicode(200), default=u''), Column(u'timezone', Unicode(200), default=u'UTC'), Column(u'activation_key', Unicode(40), default=None) ) # Definition of the "variables" table variables_table = Table(u'variables', metadata, Column(u'key', Unicode(100), primary_key=True, index=True), Column(u'value', Unicode(100), nullable=False), Column(u'type', Unicode(10), default=u'string') ) # Definition of the "categories_posts" table categories_posts_table = Table(u'categories_posts', metadata, Column(u'category_id', Integer, ForeignKey(u'categories.id'), primary_key=True), Column(u'post_id', Integer, ForeignKey(u'posts.id'), primary_key=True) ) # Definition of the "permissions_roles" bridging table permissions_roles_table = Table(u'permissions_roles', metadata, Column(u'permission_id', Integer, ForeignKey(u'permissions.id'), primary_key=True), Column(u'role_id', Integer, ForeignKey(u'roles.id'), primary_key=True) ) # Definition of the "posts_tags" table posts_tags_table = Table(u'posts_tags', metadata, Column(u'post_id', Integer, ForeignKey(u'posts.id'), primary_key=True), Column(u'tag_id', Integer, ForeignKey(u'tags.id'), primary_key=True) ) # Definition of the "roles_users" bridging table roles_users_table = Table(u'roles_users', metadata, Column(u'user_id', Integer, ForeignKey(u'users.id'), primary_key=True), Column(u'role_id', Integer, ForeignKey(u'roles.id'), primary_key=True) )