barsch / seishub.core

SeisHub - a seismological XML/SQL database hybrid
23 stars 9 forks source link

multiple schemas for one resource type #1

Closed megies closed 11 years ago

megies commented 12 years ago

@barsch, @krischer currently, only one schema file can be stored per resource type. QuakeML bases on two separate schema files however. I've tried to fix this here: https://github.com/barsch/seishub.core/blob/master/seishub/core/packages/installer.py#L58

                if env.registry.schemas.get(package_id, resourcetype_id, type):
                    msg = "Skipping Schema /%s/%s - %s"
                    msg = msg % (package_id, resourcetype_id, filename)
                    env.log.debug(msg)
                    continue

by checking against file name of the registered resources:

                to_skip = env.registry.schemas.get(package_id, resourcetype_id,
                                                   type)
                if any([str(x.getResource()).endswith(name) for x in to_skip]):

but then I get an error

WARN: ('Error storing an object.', IntegrityError('(IntegrityError) columns package_id, resourcetype_id, type are not unique',))

so I guess this case is not supported by the current setup. Where to fix this?

barsch commented 12 years ago

IntegrityError is raised because of the current SQL schema definition set in https://github.com/barsch/seishub.core/blob/master/seishub/core/registry/defaults.py#L44 - please note: type can be only one of ['XMLSchema', 'RelaxNG', 'Schematron']

deleting the UniqueConstraint should resolve the issue - however you have to update existing databases as well to make sure you cycle over all valid schemas if appropriate - right now the system expects max. one schema per resourcetype

barsch commented 11 years ago

What is the status here - should we close this as QuakeML is not complete anyway? ;)

megies commented 11 years ago

blah. whatever.

megies commented 11 years ago

Closing. We use the RelaxNG schema for validation now and that can be easily merged into one file, see barsch/seishub.plugins.seismology#3.