code: def init_or_migrate(self):
          
          assure_migrations_table_setup(self.session)
  
          # Find out what migration number, if any, this database data is at,
          # and what the latest is.
          migration_number = self.database_current_migration
  
          # Is this our first time?  Is there even a table entry for
          # this identifier?
          # If so:
          #  - create all tables
          #  - create record in migrations registry
          #  - print / inform the user
          #  - return 'inited'
          if migration_number is None:
              self.printer(u"-> Initializing %s... " % self.name_for_printing())
  
              self.init_tables()
              # auto-set at latest migration number
              self.create_new_migration_record()
  
              self.printer(u"done.\n")
              self.set_current_migration()
              return u'inited'
  
          # Run migrations, if appropriate.
          migrations_to_run = self.migrations_to_run()
          if migrations_to_run:
              self.printer(
                  u'-> Updating %s:\n' % self.name_for_printing())
              for migration_number, migration_func in migrations_to_run:
                  self.printer(
                      u'   + Running migration %s, "%s"... ' % (
                          migration_number, migration_func.func_name))
                  migration_func(self.session)
                  self.printer('done.\n')
  
              self.set_current_migration()
              return u'migrated'
  
          # Otherwise return None.  Well it would do this anyway, but
          # for clarity... ;)
          return None
docs: Initialize the database or migrate if appropriate.
  
          Returns information about whether or not we initialized
          ('inited'), migrated ('migrated'), or did nothing (None)