[ckan-dev] Issue on ckan db init

PIERRE Sylvain sylvain.pierre at bas-rhin.fr
Mon Apr 8 12:30:32 UTC 2019


Hi again list,

I will try to be more explicit with my problem:
Here is my conf
Web server : ubuntu 16.04 with CKAN package
SGBD : postgres 9.6 on windows server
sqlalchemy.url defined with right parmaters (tested with psql)

When I launch “sudo ckan db init”, I ran this error:


sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) ERREUR:  la séquence « package_extra_revision_id_seq » n'existe pas

[SQL: 'drop sequence package_extra_revision_id_seq;']

Tracing code leads me to /usr/lib/ckan/default/src/ckan/ckan/lib/cli.py > line 363 and following where I can see db command options:


class ManageDb(CkanCommand):

    '''Perform various tasks on the database.



    db create                      - alias of db upgrade

    db init                        - create and put in default data

    db clean                       - clears db (including dropping tables) and

                                     search index

    db upgrade [version no.]       - Data migrate

    db version                     - returns current version of data schema

    db dump FILE_PATH              - dump to a pg_dump file [DEPRECATED]

    db load FILE_PATH              - load a pg_dump from a file [DEPRECATED]

    db load-only FILE_PATH         - load a pg_dump from a file but don\'t do

                                     the schema upgrade or search indexing [DEPRECATED]

    db create-from-model           - create database from the model (indexes not made)

    db migrate-filestore           - migrate all uploaded data from the 2.1 filesore.


Db init option should normaly go to /usr/lib/ckan/default/src/ckan/ckan/model/__init__.py
Init_db method:

  def init_db(self):
        '''Ensures tables, const data and some default config is created.
        This method MUST be run before using CKAN for the first time.
        Before this method is run, you can either have a clean db or tables
        that may have been setup with either upgrade_db or a previous run of
        init_db.
        '''
        warnings.filterwarnings('ignore', 'SAWarning')
        self.session.rollback()
        self.session.remove()
        # sqlite database needs to be recreated each time as the
        # memory database is lost.
        if self.metadata.bind.name == 'sqlite':
            # this creates the tables, which isn't required inbetween tests
            # that have simply called rebuild_db.
            self.create_db()
        else:
            if not self.tables_created_and_initialised:
                self.upgrade_db()
                self.tables_created_and_initialised = True
        log.info('Database initialised')

Question is : why does program go to else statement rather than if statement when performing db init with postgres on windows?
This is why db init run on upgrade_db and create migration tables …

What does “self.metadata.bind.name == 'sqlite'” mean? May-be this parameter is missing with postgres on windows server?

I’ve done test with postgres on same server as Ckan and db is created (that’s not architecture we focus on…)

Thanks

Sylvain

PS : workaround with db init create-from-model, but without index, possible other missing items?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20190408/6000a001/attachment.html>


More information about the ckan-dev mailing list