Adapts your codeigniter 3 project that was built on mysql to postgresql
- Migrate your database to postgresql (I recommend to use pgloader). Your old database name should be the new schema name.
- Copy
applications
folder onto yours - Add
"postgre"
to your helpers autoload (inapplications/config/autoload.php
) - Modify your database configuration to use postgres (in
applications/config/database.php
). Example:
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'port' => 5432,
'username' => 'postgres',
'password' => '',
'database' => 'postgres',
'schema' => 'public',
'dbdriver' => 'postgre',
'sslmode' => 'allow',
...
);
- PostgreSQL converts names to lowercase unless you use double quotes in the SQL, so modify your code to access database values in lowercase. If you want compatibility with mysql, convert the mysql database to lowercase too. The names include database name, schema name, table and view name, column name, returned column/value aliases.
You can use the migrate.lisp with pgloader.
- Modify it to use your datbase URL
- Run
pgloader migrate.lisp
- Views, triggers, procedures, and functions don't get migrated. Recreate them through SQL
They don't ship pgloader binaries for Windows. Either you build them yourself, or use the linux one through WSL. Binaries built for windows are tied to your machine, idk if it's the architecture or whatever, but the one I found on the internet didn't work for me.
- Install cygwin64, choose the following packages:
- Download CCL. Extract it somewhere. Preferably close to where you would clone the pgloader project.
- Download dblib_0.95.zip. Copy all the files to cygwin64/bin.
- Duplicate dblib.dll and rename it to sybdb.dll
- Download sqlite3.dll. Copy it to cygwin64/bin.
- Clone the pgloader repo
git clone https://github.com/dimitri/pgloader.git
- Open cygwin64 terminal.
- Change directory to the pgloader project directory.
- Compile pgloader.
[your ccl.exe location] --no-init --load ./src/save.lisp
. - In build/bin, there will be a pgloader file . Rename it to pgloader.exe
- run pgloader.exe, when it popped out the error, type
:GO