github.com/brandonmartin/migrate@v3.5.4+incompatible/FAQ.md (about)

     1  # FAQ
     2  
     3  #### How is the code base structured?
     4    ```
     5    /          package migrate (the heart of everything)
     6    /cli       the CLI wrapper
     7    /database  database driver and sub directories have the actual driver implementations
     8    /source    source driver and sub directories have the actual driver implementations
     9    ```
    10  
    11  #### Why is there no `source/driver.go:Last()`?
    12    It's not needed. And unless the source has a "native" way to read a directory in reversed order,
    13    it might be expensive to do a full directory scan in order to get the last element.
    14  
    15  #### What is a NilMigration? NilVersion?
    16    NilMigration defines a migration without a body. NilVersion is defined as const -1.
    17  
    18  #### What is the difference between uint(version) and int(targetVersion)?
    19    version refers to an existing migration version coming from a source and therefor can never be negative.
    20    targetVersion can either be a version OR represent a NilVersion, which equals -1.
    21  
    22  #### What's the difference between Next/Previous and Up/Down?
    23    ```
    24    1_first_migration.up.extension           next ->  2_second_migration.up.extension      ...
    25    1_first_migration.down.extension  <- previous     2_second_migration.down.extension    ...
    26    ```
    27  
    28  #### Why two separate files (up and down) for a migration?
    29    It makes all of our lives easier. No new markup/syntax to learn for users
    30    and existing database utility tools continue to work as expected.
    31  
    32  #### How many migrations can migrate handle?
    33    Whatever the maximum positive signed integer value is for your platform.
    34    For 32bit it would be 2,147,483,647 migrations. Migrate only keeps references to
    35    the currently run and pre-fetched migrations in memory. Please note that some
    36    source drivers need to do build a full "directory" tree first, which puts some
    37    heat on the memory consumption.
    38  
    39  #### Are the table tests in migrate_test.go bloated?
    40    Yes and no. There are duplicate test cases for sure but they don't hurt here. In fact
    41    the tests are very visual now and might help new users understand expected behaviors quickly.
    42    Migrate from version x to y and y is the last migration? Just check out the test for
    43    that particular case and know what's going on instantly.
    44  
    45  #### What is Docker being used for?
    46    Only for testing. See [testing/docker.go](testing/docker.go)
    47  
    48  #### Why not just use docker-compose?
    49    It doesn't give us enough runtime control for testing. We want to be able to bring up containers fast
    50    and whenever we want, not just once at the beginning of all tests.
    51  
    52  #### Can I maintain my driver in my own repository?
    53    Yes, technically thats possible. We want to encourage you to contribute your driver to this respository though.
    54    The driver's functionality is dictated by migrate's interfaces. That means there should really
    55    just be one driver for a database/ source. We want to prevent a future where several drivers doing the exact same thing,
    56    just implemented a bit differently, co-exist somewhere on Github. If users have to do research first to find the
    57    "best" available driver for a database in order to get started, we would have failed as an open source community.
    58  
    59  #### Can I mix multiple sources during a batch of migrations?
    60    No.
    61  
    62  #### What does "dirty" database mean?
    63    Before a migration runs, each database sets a dirty flag. Execution stops if a migration fails and the dirty state persists,
    64    which prevents attempts to run more migrations on top of a failed migration. You need to manually fix the error
    65    and then "force" the expected version.
    66  
    67