SQLMIGRATION flask design thread date
This commit is contained in:
4
db_repository/README
Normal file
4
db_repository/README
Normal file
@@ -0,0 +1,4 @@
|
||||
This is a database migration repository.
|
||||
|
||||
More information at
|
||||
http://code.google.com/p/sqlalchemy-migrate/
|
||||
0
db_repository/__init__.py
Normal file
0
db_repository/__init__.py
Normal file
6
db_repository/manage.py
Normal file
6
db_repository/manage.py
Normal file
@@ -0,0 +1,6 @@
|
||||
#!.env/bin/python
|
||||
from migrate.versioning.shell import main
|
||||
import storage
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(debug='False')
|
||||
25
db_repository/migrate.cfg
Normal file
25
db_repository/migrate.cfg
Normal file
@@ -0,0 +1,25 @@
|
||||
[db_settings]
|
||||
# Used to identify which repository this database is versioned under.
|
||||
# You can use the name of your project.
|
||||
repository_id=service mail db repository
|
||||
|
||||
# The name of the database table used to track the schema version.
|
||||
# This name shouldn't already be used by your project.
|
||||
# If this is changed once a database is under version control, you'll need to
|
||||
# change the table name in each database too.
|
||||
version_table=migrate_version
|
||||
|
||||
# When committing a change script, Migrate will attempt to generate the
|
||||
# sql for all supported databases; normally, if one of them fails - probably
|
||||
# because you don't have that database installed - it is ignored and the
|
||||
# commit continues, perhaps ending successfully.
|
||||
# Databases in this list MUST compile successfully during a commit, or the
|
||||
# entire commit will fail. List the databases your application will actually
|
||||
# be using to ensure your updates to that database work properly.
|
||||
# This must be a list; example: ['postgres','sqlite']
|
||||
required_dbs=[]
|
||||
|
||||
# When creating new change scripts, Migrate will stamp the new script with
|
||||
# a version number. By default this is latest_version + 1. You can set this
|
||||
# to 'true' to tell Migrate to use the UTC timestamp instead.
|
||||
use_timestamp_numbering=False
|
||||
1
db_repository/storage
Symbolic link
1
db_repository/storage
Symbolic link
@@ -0,0 +1 @@
|
||||
storage
|
||||
33
db_repository/versions/002_add_date_to_threads.py
Normal file
33
db_repository/versions/002_add_date_to_threads.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from sqlalchemy import *
|
||||
from migrate import *
|
||||
|
||||
|
||||
from migrate.changeset import schema
|
||||
pre_meta = MetaData()
|
||||
post_meta = MetaData()
|
||||
threads = Table('threads', post_meta,
|
||||
Column('created_at', TIMESTAMP, nullable=False),
|
||||
Column('updated_at', TIMESTAMP, nullable=False),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('firstmail', Integer),
|
||||
Column('date', DateTime),
|
||||
Column('islabeled', Boolean),
|
||||
Column('opened', Boolean),
|
||||
Column('body', Text),
|
||||
)
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
# Upgrade operations go here. Don't create your own engine; bind
|
||||
# migrate_engine to your metadata
|
||||
pre_meta.bind = migrate_engine
|
||||
post_meta.bind = migrate_engine
|
||||
post_meta.tables['threads'].columns['date'].create()
|
||||
|
||||
|
||||
def downgrade(migrate_engine):
|
||||
# Operations to reverse the above upgrade go here.
|
||||
pre_meta.bind = migrate_engine
|
||||
post_meta.bind = migrate_engine
|
||||
post_meta.tables['threads'].columns['date'].drop()
|
||||
|
||||
34
db_repository/versions/003_maintopic.py
Normal file
34
db_repository/versions/003_maintopic.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from sqlalchemy import *
|
||||
from migrate import *
|
||||
|
||||
|
||||
from migrate.changeset import schema
|
||||
pre_meta = MetaData()
|
||||
post_meta = MetaData()
|
||||
threads = Table('threads', post_meta,
|
||||
Column('created_at', TIMESTAMP, nullable=False),
|
||||
Column('updated_at', TIMESTAMP, nullable=False),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('firstmail', Integer),
|
||||
Column('date', DateTime),
|
||||
Column('islabeled', Boolean),
|
||||
Column('opened', Boolean),
|
||||
Column('body', Text),
|
||||
Column('maintopic', String),
|
||||
)
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
# Upgrade operations go here. Don't create your own engine; bind
|
||||
# migrate_engine to your metadata
|
||||
pre_meta.bind = migrate_engine
|
||||
post_meta.bind = migrate_engine
|
||||
post_meta.tables['threads'].columns['maintopic'].create()
|
||||
|
||||
|
||||
def downgrade(migrate_engine):
|
||||
# Operations to reverse the above upgrade go here.
|
||||
pre_meta.bind = migrate_engine
|
||||
post_meta.bind = migrate_engine
|
||||
post_meta.tables['threads'].columns['maintopic'].drop()
|
||||
|
||||
0
db_repository/versions/__init__.py
Normal file
0
db_repository/versions/__init__.py
Normal file
Reference in New Issue
Block a user