How to migrate to another databaseΒΆ

You can migrate your data to another database.

For example, you developed your project with SQLite database and want to move to Postgress.

To do this, follow these steps:

  1. Create an empty Postgress database

  2. Create a new project with this database

  3. Export the metadata of the SQLite project to a zip file in the Application Builder by clicking the Export button.

  4. Import the metadata to the new project. The web application with create database structures in the Postgress database.

  5. copy data from SQlite to Postgress database using the copy_database method of the task:

    • within the ProjectTask create the following Server Module function (adjust the below database path with correct one):

      from jam.db.db_modules import SQLITE
      
      def copy_db(task):
          task.copy_database(SQLITE, '/home/work/demo/demo.sqlite')
      
    • then, execute it with the one of the following ways:

      • call this function in the on_created event handler:

        from jam.db.db_modules import SQLITE
        
        def copy_db(task):
            task.copy_database(SQLITE, '/home/work/demo/demo.sqlite')
        
        def on_created(task):
          copy_db(task)
        
      • create a button in some form and use the task server method to execute it

        function on_view_form_created(item) {
          item.add_view_button('Copy DB').click(function() {
            task.server('copy_db')
          });
        }
        
      • or run from from debugging console of the browser:

        task.server('copy_db')
        
  6. Remove the code that was used immediately after this procedure.

Note

You can not migrate to SQLite database if the current database has foreign keys.