def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'users', sa.Column('uuid', postgresql.UUID(as_uuid=True), server_default=sa.text('uuid_generate_v4()'), nullable=False), sa.Column('username', sa.String(length=64), nullable=True), sa.Column('passhash', sa.Binary(), nullable=False), sa.Column('salt', sa.Binary(), nullable=False), sa.Column('acl', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('uuid'), sa.UniqueConstraint('username'), sa.UniqueConstraint('uuid')) op.create_table( 'interfaces', sa.Column('uuid', postgresql.UUID(as_uuid=True), server_default=sa.text('uuid_generate_v4()'), nullable=False), sa.Column('device_uuid', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('read_acl', sa.Integer(), nullable=True), sa.Column('write_acl', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['device_uuid'], ['devices.uuid'], ), sa.PrimaryKeyConstraint('uuid'), sa.UniqueConstraint('device_uuid'), sa.UniqueConstraint('uuid')) op.create_unique_constraint(None, 'device_room', ['uuid']) op.create_unique_constraint(None, 'rooms', ['uuid'])
def downgrade() -> None: # sqlite has no `drop column` command, so we recreate the original table # then load it from a temp table conn = op.get_bind() conn.execute("PRAGMA legacy_alter_table=ON") op.rename_table("journalists", "journalists_tmp") op.create_table( "journalists", sa.Column("id", sa.Integer(), nullable=False), sa.Column("username", sa.String(length=255), nullable=False), sa.Column("pw_salt", sa.Binary(), nullable=True), sa.Column("pw_hash", sa.Binary(), nullable=True), sa.Column("is_admin", sa.Boolean(), nullable=True), sa.Column("otp_secret", sa.String(length=16), nullable=True), sa.Column("is_totp", sa.Boolean(), nullable=True), sa.Column("hotp_counter", sa.Integer(), nullable=True), sa.Column("last_token", sa.String(length=6), nullable=True), sa.Column("created_on", sa.DateTime(), nullable=True), sa.Column("last_access", sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint("username"), ) conn.execute( """ INSERT INTO journalists SELECT id, username, pw_salt, pw_hash, is_admin, otp_secret, is_totp, hotp_counter, last_token, created_on, last_access FROM journalists_tmp """ ) op.drop_table("journalists_tmp")
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'setpoint_params', sa.Column('uuid', postgresql.UUID(as_uuid=True), server_default=sa.text('uuid_generate_v4()'), nullable=False), sa.Column('ep_uuid', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('value', sa.Binary(), nullable=True), sa.ForeignKeyConstraint( ['ep_uuid'], ['endpoints.uuid'], ), sa.PrimaryKeyConstraint('uuid'), sa.UniqueConstraint('uuid')) op.create_table( 'setpoint_pairs', sa.Column('uuid', postgresql.UUID(as_uuid=True), server_default=sa.text('uuid_generate_v4()'), nullable=False), sa.Column('params_uuid', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('name', sa.String(length=64), nullable=True), sa.Column('value', sa.Binary(), nullable=True), sa.ForeignKeyConstraint( ['params_uuid'], ['setpoint_params.uuid'], ), sa.PrimaryKeyConstraint('uuid'), sa.UniqueConstraint('uuid')) op.create_unique_constraint(None, 'conditions', ['uuid']) op.create_unique_constraint(None, 'instruction_params', ['uuid']) op.create_unique_constraint(None, 'instructions', ['uuid']) op.execute("COMMIT") op.execute("ALTER TYPE drivertypeenum ADD VALUE 'setpoint'")
def upgrade(): HASH_SIZE = 32 users = sa.table( 'users', sa.Column('id'), sa.Column('full_name', sa.String), sa.Column('email', sa.String), sa.Column('_salt', sa.Binary(HASH_SIZE)), sa.Column('_hashed_password', sa.Binary(HASH_SIZE)), sa.Column('_active', sa.Boolean), sa.Column('_is_admin', sa.Boolean), ) default_password = '******' salt = os.urandom(HASH_SIZE) pwd = hashlib.sha256(salt + bytes(default_password, encoding='utf8')).digest() op.bulk_insert(users, [{ 'full_name': 'Administrator', 'email': '*****@*****.**', '_salt': salt, '_hashed_password': pwd, '_active': True, '_is_admin': True }])
class User(Base): __tablename__ = 'users' sid = sa.Column(sa.BigInteger, primary_key=True) name = sa.Column(sa.String(length=100), nullable=False) type_id = sa.Column(sa.Integer, sa.ForeignKey('types.id')) waiverSigned = sa.Column(sa.DateTime) photo = sa.Column(sa.String(length=100), default='') location_id = sa.Column(sa.INTEGER, sa.ForeignKey('locations.id'), nullable=False, primary_key=True) pin = sa.Column(sa.Binary(length=16)) pin_salt = sa.Column(sa.Binary(length=16)) def set_pin(self, pin): self.pin_salt = os.urandom(16) # 100,000 rounds of sha256 w/ a random salt self.pin = hashlib.pbkdf2_hmac('sha256', bytearray(pin, 'utf-8'), self.pin_salt, 100000) def verify_pin(self, attempt): digest = hashlib.pbkdf2_hmac('sha256', bytearray(attempt, 'utf-8'), self.pin_salt, 100000) return hmac.compare_digest(self.pin, digest) def __repr__(self): return "<Location %s>" % self.name type = relationship('Type') location = relationship('Location') trainings = relationship('Training', foreign_keys=[Training.trainee_id]) access = relationship('Access', order_by='Access.timeIn') cards = relationship('HawkCard') def __repr__(self): return "<User A%d (%s)>" % (self.sid, self.name)
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column( 'cluster', sa.Column('k8s_service_account_private_key', sa.Binary(), nullable=True)) op.add_column( 'cluster', sa.Column('k8s_service_account_public_key', sa.Binary(), nullable=True)) op.execute( 'UPDATE cluster SET k8s_service_account_private_key=(SELECT key FROM credentials_data WHERE credentials_data.id = cluster.service_account_keypair_id)' ) op.execute( 'UPDATE cluster SET k8s_service_account_public_key=(SELECT cert FROM credentials_data WHERE credentials_data.id = cluster.service_account_keypair_id)' ) op.alter_column('cluster', 'k8s_service_account_private_key', nullable=False) op.alter_column('cluster', 'k8s_service_account_public_key', nullable=False) op.drop_constraint('cluster_service_account_keypair_id_fkey', 'cluster', type_='foreignkey') op.drop_column('cluster', 'service_account_keypair_id')
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('otp_session', sa.Column('secret', sa.String(length=100), nullable=False), sa.Column('form', sa.Binary(), nullable=True), sa.Column('session', sa.Binary(), nullable=True), sa.PrimaryKeyConstraint('secret')) op.create_table( 'session', sa.Column('id', sa.String(length=36), nullable=False), sa.Column('username', sa.String(length=64), nullable=False), sa.Column('created', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table('phone_codes', sa.Column('code', sa.String(length=6), nullable=False), sa.Column('session', sa.String(length=36), nullable=True), sa.ForeignKeyConstraint( ['session'], ['session.id'], ), sa.PrimaryKeyConstraint('code')) op.create_table( 'token', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=64), nullable=False), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('token', sa.String(length=36), nullable=True), sa.Column('session', sa.String(length=36), nullable=True), sa.Column('used', sa.Boolean(), nullable=True), sa.ForeignKeyConstraint( ['session'], ['session.id'], ), sa.PrimaryKeyConstraint('id'))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'identity', sa.Column('id', sa.Integer(), nullable=False), sa.Column('issuer_id', sa.Integer(), nullable=True), sa.Column('name', sa.String(length=255), nullable=False), sa.ForeignKeyConstraint( ['issuer_id'], ['identity.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('issuer_id', 'name', name='_issuer_name_uc'), sa.UniqueConstraint('name')) op.create_table( 'pair', sa.Column('id', sa.Integer(), nullable=False), sa.Column('identity_id', sa.Integer(), nullable=False), sa.Column('issued_at', sa.DateTime(), nullable=True), sa.Column('cert', sa.Binary(), nullable=False), sa.Column('key', sa.Binary(), nullable=False), sa.ForeignKeyConstraint( ['identity_id'], ['identity.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('identity_id', 'issued_at', name='_identity_issued_at_uc'))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('tag', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=100), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name')) op.create_table('user', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(), nullable=False), sa.Column('email', sa.String(), nullable=False), sa.Column('password_hash', sa.Binary(), nullable=False), sa.Column('password_salt', sa.Binary(), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email')) op.create_table( 'post', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('title', sa.String(length=200), nullable=False), sa.Column('text', sa.Text(), nullable=False), sa.Column('published_date_time', sa.DateTime(), nullable=True), sa.Column('published', sa.Boolean(), nullable=True), sa.Column('image_uuid', sa.String(length=36), nullable=True), sa.Column('image_name', sa.String(length=100), nullable=True), sa.ForeignKeyConstraint( ['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table('post_tag', sa.Column('post_id', sa.Integer(), nullable=False), sa.Column('tag_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ['post_id'], ['post.id'], ), sa.ForeignKeyConstraint( ['tag_id'], ['tag.id'], ), sa.PrimaryKeyConstraint('post_id', 'tag_id'))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'trades', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('account_id', sa.Integer(), nullable=False), sa.Column('stock_id', sa.Integer(), nullable=False), sa.Column('trade_type', sa.Enum('buy', 'sell', native_enum=False), nullable=False), sa.Column('process_date', sa.DateTime(), nullable=False), sa.Column('price', sa.Numeric(precision=19, scale=2, asdecimal=False), nullable=False), sa.Column('shares', sa.Integer(), nullable=False), sa.PrimaryKeyConstraint('id')) op.create_table( 'users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=80), nullable=False), sa.Column('password', sa.Binary(), nullable=False), sa.Column('salt', sa.Binary(), nullable=False), sa.Column('first_name', sa.String(length=50), nullable=True), sa.Column('last_name', sa.String(length=50), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('username')) op.create_table( 'accounts', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('cash_amount', sa.Numeric(precision=19, scale=2, asdecimal=False), nullable=True), sa.Column('equity_amount', sa.Numeric(precision=19, scale=2, asdecimal=False), nullable=True), sa.Column('initial_amount', sa.Numeric(precision=19, scale=2, asdecimal=False), nullable=True), sa.ForeignKeyConstraint( ['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table( 'stocks', sa.Column('id', sa.Integer(), nullable=False), sa.Column('account_id', sa.Integer(), nullable=True), sa.Column('bought_at', sa.Numeric(precision=19, scale=2, asdecimal=False), nullable=False), sa.Column('bought_on', sa.DateTime(), nullable=False), sa.Column('sold_on', sa.DateTime(), nullable=True), sa.Column('initial_cost', sa.Numeric(precision=19, scale=2, asdecimal=False), nullable=False), sa.Column('shares', sa.Integer(), nullable=False), sa.Column('symbol', sa.String(length=5), nullable=False), sa.ForeignKeyConstraint( ['account_id'], ['accounts.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('symbol'))
def upgrade(): op.create_table( "users", sa.Column("id", sa.Integer(), primary_key=True), sa.Column("name", sa.String(50), nullable=False), sa.Column("username", sa.String(50), nullable=False, unique=True), sa.Column("password", sa.Binary(), nullable=False), sa.Column("salt", sa.Binary(), nullable=False), sa.Column("is_authenticated", sa.Boolean(), nullable=False, default=False), )
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('blog_posts', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('modified_at', sa.DateTime(), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('author_id', sa.Integer(), nullable=True), sa.Column('title', sa.String(length=100), nullable=False), sa.Column('body', sa.String(length=200), nullable=False), sa.Column('image', sa.Binary(), nullable=False), sa.ForeignKeyConstraint( ['author_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table( 'bookmarks_user', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('modified_at', sa.DateTime(), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('bookmark_user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['bookmark_user_id'], ['users.id'], ), sa.ForeignKeyConstraint( ['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table('profiles', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('modified_at', sa.DateTime(), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('nickname', sa.String(length=80), nullable=True), sa.Column('comment', sa.String(length=200), nullable=True), sa.Column('icon', sa.Binary(), nullable=True), sa.ForeignKeyConstraint( ['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table( 'bookmarks_post', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('modified_at', sa.DateTime(), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('bookmark_post_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['bookmark_post_id'], ['blog_posts.id'], ), sa.ForeignKeyConstraint( ['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id'))
def upgrade() -> None: conn = op.get_bind() conn.execute("PRAGMA legacy_alter_table=ON") # Save existing journalist table. op.rename_table("journalists", "journalists_tmp") # Add nonce column. op.add_column("journalists_tmp", sa.Column("session_nonce", sa.Integer())) # Populate nonce column. journalists = conn.execute( sa.text("SELECT * FROM journalists_tmp")).fetchall() for journalist in journalists: conn.execute( sa.text("""UPDATE journalists_tmp SET session_nonce=0 WHERE id=:id""").bindparams(id=journalist.id)) # Now create new table with null constraint applied. op.create_table( "journalists", sa.Column("id", sa.Integer(), nullable=False), sa.Column("uuid", sa.String(length=36), nullable=False), sa.Column("username", sa.String(length=255), nullable=False), sa.Column("first_name", sa.String(length=255), nullable=True), sa.Column("last_name", sa.String(length=255), nullable=True), sa.Column("pw_salt", sa.Binary(), nullable=True), sa.Column("pw_hash", sa.Binary(), nullable=True), sa.Column("passphrase_hash", sa.String(length=256), nullable=True), sa.Column("is_admin", sa.Boolean(), nullable=True), sa.Column("session_nonce", sa.Integer(), nullable=False), sa.Column("otp_secret", sa.String(length=16), nullable=True), sa.Column("is_totp", sa.Boolean(), nullable=True), sa.Column("hotp_counter", sa.Integer(), nullable=True), sa.Column("last_token", sa.String(length=6), nullable=True), sa.Column("created_on", sa.DateTime(), nullable=True), sa.Column("last_access", sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint("username"), sa.UniqueConstraint("uuid"), ) conn.execute(""" INSERT INTO journalists SELECT id, uuid, username, first_name, last_name, pw_salt, pw_hash, passphrase_hash, is_admin, session_nonce, otp_secret, is_totp, hotp_counter, last_token, created_on, last_access FROM journalists_tmp """) # Now delete the old table. op.drop_table("journalists_tmp")
def create_api_data_table(engine): metadata = db.MetaData() api_data = db.Table('api_data', metadata, db.Column('id',db.Integer(), primary_key=True,nullable=False), db.Column('year',db.Integer()), db.Column('country',db.String(255)), db.Column('genre',db.Binary()), db.Column('style', db.Binary()), db.Column('label', db.Binary()), db.Column('community_have',db.Integer()), db.Column('community_want',db.Integer()), db.Column('formats',db.Binary()) )
def upgrade(): # Save existing journalist table. op.rename_table("journalists", "journalists_tmp") # Add UUID column. op.add_column("journalists_tmp", sa.Column("uuid", sa.String(length=36))) # Add UUIDs to journalists_tmp table. conn = op.get_bind() journalists = conn.execute( sa.text("SELECT * FROM journalists_tmp")).fetchall() for journalist in journalists: conn.execute( sa.text("""UPDATE journalists_tmp SET uuid=:journalist_uuid WHERE id=:id""").bindparams(journalist_uuid=str(uuid.uuid4()), id=journalist.id)) # Now create new table with unique constraint applied. op.create_table( "journalists", sa.Column("id", sa.Integer(), nullable=False), sa.Column("uuid", sa.String(length=36), nullable=False), sa.Column("username", sa.String(length=255), nullable=False), sa.Column("pw_salt", sa.Binary(), nullable=True), sa.Column("pw_hash", sa.Binary(), nullable=True), sa.Column("passphrase_hash", sa.String(length=256), nullable=True), sa.Column("is_admin", sa.Boolean(), nullable=True), sa.Column("otp_secret", sa.String(length=16), nullable=True), sa.Column("is_totp", sa.Boolean(), nullable=True), sa.Column("hotp_counter", sa.Integer(), nullable=True), sa.Column("last_token", sa.String(length=6), nullable=True), sa.Column("created_on", sa.DateTime(), nullable=True), sa.Column("last_access", sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint("username"), sa.UniqueConstraint("uuid"), ) conn = op.get_bind() conn.execute(""" INSERT INTO journalists SELECT id, uuid, username, pw_salt, pw_hash, passphrase_hash, is_admin, otp_secret, is_totp, hotp_counter, last_token, created_on, last_access FROM journalists_tmp """) # Now delete the old table. op.drop_table("journalists_tmp")
def upgrade(): # Save existing journalist table. op.rename_table('journalists', 'journalists_tmp') # Add nonce column. op.add_column('journalists_tmp', sa.Column('session_nonce', sa.Integer())) # Populate nonce column. conn = op.get_bind() journalists = conn.execute( sa.text("SELECT * FROM journalists_tmp")).fetchall() for journalist in journalists: conn.execute( sa.text("""UPDATE journalists_tmp SET session_nonce=0 WHERE id=:id""").bindparams(id=journalist.id)) # Now create new table with null constraint applied. op.create_table( 'journalists', sa.Column('id', sa.Integer(), nullable=False), sa.Column('uuid', sa.String(length=36), nullable=False), sa.Column('username', sa.String(length=255), nullable=False), sa.Column('first_name', sa.String(length=255), nullable=True), sa.Column('last_name', sa.String(length=255), nullable=True), sa.Column('pw_salt', sa.Binary(), nullable=True), sa.Column('pw_hash', sa.Binary(), nullable=True), sa.Column('passphrase_hash', sa.String(length=256), nullable=True), sa.Column('is_admin', sa.Boolean(), nullable=True), sa.Column('session_nonce', sa.Integer(), nullable=False), sa.Column('otp_secret', sa.String(length=16), nullable=True), sa.Column('is_totp', sa.Boolean(), nullable=True), sa.Column('hotp_counter', sa.Integer(), nullable=True), sa.Column('last_token', sa.String(length=6), nullable=True), sa.Column('created_on', sa.DateTime(), nullable=True), sa.Column('last_access', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('username'), sa.UniqueConstraint('uuid')) conn = op.get_bind() conn.execute(''' INSERT INTO journalists SELECT id, uuid, username, first_name, last_name, pw_salt, pw_hash, passphrase_hash, is_admin, session_nonce, otp_secret, is_totp, hotp_counter, last_token, created_on, last_access FROM journalists_tmp ''') # Now delete the old table. op.drop_table('journalists_tmp')
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_column('email_notification', 'next_event') op.drop_column('email_notification', 'new_paper') op.drop_column('email_notification', 'session_accept_reject') op.drop_column('email_notification', 'session_schedule') op.add_column('email_notification', sa.Column('next_event', sa.Binary(), nullable=True)) op.add_column('email_notification', sa.Column('new_paper', sa.Binary(), nullable=True)) op.add_column( 'email_notification', sa.Column('session_accept_reject', sa.Binary(), nullable=True)) op.add_column('email_notification', sa.Column('session_schedule', sa.Binary(), nullable=True))
class PageDocument(Base): """ A data class representing the information crawled from a web page. """ __tablename__ = "Document" doc_id = sa.Column("id", sa.BigInteger().with_variant(sa.Integer, "sqlite"), primary_key=True) title = sa.Column("title", sa.String(500), nullable=False) url = sa.Column("url", sa.String(500), nullable=False) content = sa.Column("content", sa.Binary(2000000), nullable=False) checksum = sa.Column("checksum", sa.Binary(128), nullable=False) anchors = relationship("Anchor") headers = relationship("Header") texts = relationship("TextSection") def __init__(self, doc_id=0, title="", checksum=b"", url="", content=b"", anchors=(), texts=(), headers=()): """ creates a new PageDocument :param doc_id: the id of the document in the main repository. :param title: the title of the page. :param checksum: the checksum of the page. :param url: the url of the page. :param html: the html of the page. :param anchors: the anchors on the page. :param texts: the text sectins on the page. :param headers: the headings on the page. """ self.doc_id = doc_id self.title = title self.checksum = checksum self.url = url self.content = content self.anchors.extend(anchors) self.texts.extend(texts) self.headers.extend(headers) def __repr__(self) -> str: return str(self.__dict__)
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'PodCast', sa.Column('id', sa.Integer(), nullable=False), sa.Column('artistName', sa.String(), nullable=True), sa.Column('podCastId', sa.Integer(), nullable=True), sa.Column('releaseDate', sa.Date(), nullable=True), sa.Column('name', sa.String(), nullable=True), sa.Column('kind', sa.String(), nullable=True), sa.Column('copyright', sa.String(), nullable=True), sa.Column('artistId', sa.Integer(), nullable=True), sa.Column('contentAdvisoryRating', sa.String(), nullable=True), sa.Column('artistUrl', sa.String(), nullable=True), sa.Column('artworkUrl100', sa.String(), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table('User', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(), nullable=True), sa.Column('email', sa.String(), nullable=True), sa.Column('password', sa.Binary(), nullable=True), sa.Column('access', sa.String(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'), sa.UniqueConstraint('username')) op.create_table('Genre', sa.Column('id', sa.Integer(), nullable=False), sa.Column('genreId', sa.Integer(), nullable=True), sa.Column('name', sa.String(), nullable=True), sa.Column('url', sa.String(), nullable=True), sa.Column('podCast', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['podCast'], ['PodCast.id'], ), sa.PrimaryKeyConstraint('id'))
class SignoffStep(db.Model): """ Recording signoff steps as distinct entities """ __tablename__ = 'shipit_signoff_steps' uid = sa.Column(sa.String(80), primary_key=True) # uid = sa.Column(sa.String(80), nullable=False) state = sa.Column(sa.Enum(SigningStatus), default=SigningStatus.starting) status_message = sa.Column(sa.String(200), nullable=True) created = sa.Column(sa.DateTime, default=datetime.datetime.utcnow) completed = sa.Column(sa.DateTime, nullable=True) policy = sa.Column(sa.Binary()) signatures = db.relationship('Signature') @property def policy_data(self): if not self.policy: return None return pickle.loads(self.policy) def delete(self): """ Delete step, and associated signatures """ signatures = Signature.query.filter_by(step_uid=self.uid).all() for signature in signatures: signature.delete() db.session.delete(self) db.session.commit()
def upgrade(): op.alter_column('payment_transaction', 'checksum', existing_type=sa.String(40), type_=sa.Binary(32), existing_nullable=True, postgresql_using='checksum::bytea')
def upgrade(pyramid_env): with context.begin_transaction(): op.create_table( 'old_password', sa.Column( 'id', sa.Integer, primary_key=True ), sa.Column( 'user_id', sa.Integer, sa.ForeignKey( 'user.id', ondelete="CASCADE", onupdate="CASCADE" ), nullable=False, index=True ), sa.Column( 'password', sa.Binary(115), ), )
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'action', sa.Column('id', sa.Integer(), nullable=False), sa.Column('event_name', sa.String(length=50), nullable=False), sa.Column('timestamp', sa.DateTime(), nullable=True), sa.Column('_data', sa.Text(), nullable=True), sa.Column('message', sa.String(length=500), nullable=True), sa.Column('status', sa.Boolean(), nullable=False), sa.PrimaryKeyConstraint('id')) op.create_table( 'users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=80), nullable=False), sa.Column('email', sa.String(length=80), nullable=False), sa.Column('password', sa.Binary(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('first_name', sa.String(length=30), nullable=True), sa.Column('last_name', sa.String(length=30), nullable=True), sa.Column('active', sa.Boolean(), nullable=True), sa.Column('is_admin', sa.Boolean(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'), sa.UniqueConstraint('username')) op.create_table('roles', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=80), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name'))
def upgrade(): op.create_table( 'users', sa.Column('username', sa.String(length=24), nullable=False), sa.Column('email', sa.String(length=255), nullable=False), sa.Column('password', sa.Binary(), nullable=False), )
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=40), nullable=False), sa.Column('email', sa.String(length=255), nullable=False), sa.Column('admin', sa.Boolean(), nullable=True), sa.Column('hashed_password', sa.Binary(), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'), sa.UniqueConstraint('username')) op.create_table( 'missings', sa.Column('id', sa.Integer(), nullable=False), sa.Column('fullName', sa.String(length=100), nullable=False), sa.Column('age', sa.Integer(), nullable=False), sa.Column('tribalAffiliation', sa.String(length=20), nullable=False), sa.Column('location', sa.String(length=50), nullable=False), sa.Column('lat', sa.Float(), nullable=False), sa.Column('lng', sa.Float(), nullable=False), sa.Column('dateLastSeen', sa.DateTime(), nullable=False), sa.Column('details', sa.String(length=1000), nullable=True), sa.Column('status', sa.String(length=10), nullable=False), sa.Column('userId', sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ['userId'], ['users.id'], ), sa.PrimaryKeyConstraint('id'))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('email', sa.String(), nullable=False), sa.Column('_password', sa.Binary(), nullable=False), sa.Column('authenticated', sa.Boolean(), nullable=True), sa.Column('email_confirmation_sent_on', sa.DateTime(), nullable=True), sa.Column('email_confirmed', sa.Boolean(), nullable=True), sa.Column('email_confirmed_on', sa.DateTime(), nullable=True), sa.Column('registered_on', sa.DateTime(), nullable=True), sa.Column('last_logged_in', sa.DateTime(), nullable=True), sa.Column('current_logged_in', sa.DateTime(), nullable=True), sa.Column('role', sa.String(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email')) op.create_table('books', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.String(), nullable=False), sa.Column('author', sa.String(), nullable=True), sa.Column('read_date', sa.String(), nullable=True), sa.Column('notes', sa.String(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id'))
def upgrade(): op.create_table( 'source_components', sa.Column('name', sa.String(), nullable=False), sa.Column('value', sa.Binary(), nullable=False), sa.Column('description', sa.Text(), nullable=True), sa.Column('username', sa.String(), nullable=True), sa.PrimaryKeyConstraint('name', name=op.f('pk_source_components')))
class Job(Base): __tablename__ = "jobs" id = sa.Column(sa.Integer, primary_key=True) created = sa.Column(sa.DateTime, nullable=False, default=datetime.utcnow) updated = sa.Column(sa.DateTime, nullable=False, default=datetime.utcnow) manifest = sa.Column(sa.Binary(), nullable=False) owner_id = sa.Column(UUID, sa.ForeignKey("users.id", ondelete="cascade"), nullable=True) owner = sa.orm.relationship("User", backref=sa.orm.backref("jobs", cascade="all,delete")) items_spec = sa.Column(sa.String(), nullable=True) items = sa.Column( sa.Enum(ItemsSelection), nullable=False, default=ItemsSelection.all, ) # job_group_id = sa.Column(sa.Integer, sa.ForeignKey('job_group.id')) # job_group = sa.orm.relationship('JobGroup', backref=sa.orm.backref('jobs')) # secrets = sa.Column(sa.Boolean, nullable=False, server_default="t") # note = sa.Column(sa.Unicode(4096)) # tags = sa.Column(sa.String()) # runner = sa.Column(sa.String) status = sa.Column( sa.Enum(JobStatus), nullable=False, default=JobStatus.pending, ) tasks = sa.orm.relationship('Task', cascade="all,delete-orphan")
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'Patient', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(), nullable=True), sa.Column('age', sa.Integer(), nullable=True), sa.Column('visits', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('pk_Patient')), sa.UniqueConstraint('username', name=op.f('uq_Patient_username'))) op.create_table( 'PatientVisitDetails', sa.Column('visit_id', sa.Integer(), nullable=False), sa.Column('patient_id', sa.Integer(), nullable=True), sa.Column('date_time', sa.DateTime(), nullable=True), sa.Column('doctor_id', sa.Integer(), nullable=True), sa.Column('question_1', sa.String(), nullable=False), sa.Column('question_2', sa.String(), nullable=False), sa.Column('question_3', sa.String(), nullable=False), sa.Column('question_4', sa.String(), nullable=False), sa.Column('question_5', sa.String(), nullable=False), sa.Column('question_6', sa.String(), nullable=False), sa.PrimaryKeyConstraint('visit_id', name=op.f('pk_PatientVisitDetails'))) op.create_table( 'User', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(), nullable=True), sa.Column('email', sa.String(), nullable=True), sa.Column('password', sa.Binary(), nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('pk_User')), sa.UniqueConstraint('email', name=op.f('uq_User_email')), sa.UniqueConstraint('username', name=op.f('uq_User_username')))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('comic', sa.Column('id', sa.String(length=30), nullable=False), sa.Column('month', sa.String(length=2), nullable=False), sa.Column('num', sa.Integer(), nullable=False), sa.Column('link', sa.String(length=100), nullable=False), sa.Column('year', sa.String(length=4), nullable=False), sa.Column('news', sa.Text(), nullable=False), sa.Column('safe_title', sa.Text(), nullable=False), sa.Column('transcript', sa.Text(), nullable=False), sa.Column('alt', sa.Text(), nullable=False), sa.Column('img', sa.String(length=200), nullable=False), sa.Column('title', sa.String(length=100), nullable=False), sa.Column('day', sa.String(length=2), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('num')) op.create_table( 'users', sa.Column('id', sa.String(length=30), nullable=False), sa.Column('first_name', sa.String(length=80), nullable=False), sa.Column('last_name', sa.String(length=80), nullable=False), sa.Column('email', sa.String(length=100), nullable=False), sa.Column('password', sa.Binary(), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'), sa.UniqueConstraint('id')) op.create_table('userprofile', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.String(length=30), nullable=False), sa.ForeignKeyConstraint( ['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id'))