add a organization table (addresses #40)
* development.ini: - change testing database to PostgreSQL - set required database version to 4 * data/dbrepo/versions/004_Add_organization_table.py: - create/drop organization table - add organizationid foreign key reference to client table * gnuviechadmin/backend/tables.py: - add reflected organization_table
This commit is contained in:
		
							parent
							
								
									33696436a0
								
							
						
					
					
						commit
						d4ba46a329
					
				
					 3 changed files with 37 additions and 3 deletions
				
			
		
							
								
								
									
										29
									
								
								data/dbrepo/versions/004_Add_organization_table.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								data/dbrepo/versions/004_Add_organization_table.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| from sqlalchemy import MetaData, Table, Column, Integer, Unicode, ForeignKey | ||||
| from migrate import migrate_engine | ||||
| from migrate.changeset.schema import create_column | ||||
| from gnuviechadmin.config import config | ||||
| 
 | ||||
| dbschema = None | ||||
| if 'database.schema' in config: | ||||
|     dbschema = config['database.schema'] | ||||
| 
 | ||||
| meta = MetaData(migrate_engine) | ||||
| client = Table('client', meta, schema = dbschema, autoload = True) | ||||
| organization = Table( | ||||
|     'organization', meta, | ||||
|     Column('organizationid', Integer, primary_key = True), | ||||
|     Column('name', Unicode(200), nullable = False, unique = True), | ||||
|     schema = dbschema, | ||||
|     useexisting = True) | ||||
| 
 | ||||
| def upgrade(): | ||||
|     organization.create() | ||||
|     col = Column('organizationid', Integer, | ||||
|                  ForeignKey(organization.c.organizationid), | ||||
|                  nullable = True) | ||||
|     create_column(col, client) | ||||
| 
 | ||||
| 
 | ||||
| def downgrade(): | ||||
|     client.c.organizationid.drop() | ||||
|     organization.drop() | ||||
|  | @ -12,11 +12,11 @@ use = egg:gnuviechadmin#cli | |||
| # sqlalchemy. The default is an sqlite in memory database which is not | ||||
| # very usable for a real installation. | ||||
| # | ||||
| sqlalchemy.uri = sqlite:///%(here)s/gva.db | ||||
| sqlalchemy.uri = postgres://localhost/gvatest | ||||
| sqlalchemy.echo = false | ||||
| 
 | ||||
| database.repository = %(here)s/data/dbrepo | ||||
| migrate.required_version = 3 | ||||
| migrate.required_version = 4 | ||||
| templatedir = %(here)s/data/templates | ||||
| mailtemplates = %(templatedir)s/mails | ||||
| 
 | ||||
|  |  | |||
|  | @ -19,7 +19,7 @@ | |||
| # | ||||
| # Version: $Id$ | ||||
| 
 | ||||
| from sqlalchemy import MetaData, Table | ||||
| from sqlalchemy import MetaData, Table, Column, Unicode | ||||
| from sqlalchemy.orm import mapper, relation | ||||
| from sqlalchemy.exceptions import NoSuchTableError | ||||
| import sys | ||||
|  | @ -68,6 +68,11 @@ Trying automatic versioning.""") | |||
|     dbschema = None | ||||
|     if 'database.schema' in config: | ||||
|         dbschema = config['database.schema'] | ||||
| 
 | ||||
|     organization_table = Table( | ||||
|         'organization', meta, | ||||
|         Column('name', Unicode(200)), | ||||
|         schema = dbschema, autoload = True) | ||||
|      | ||||
|     (client_table, sysuser_table, domain_table, \ | ||||
|          record_table, supermaster_table, mailaccount_table, \ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue