Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As a user, when I build a project, I should be able to create database migrations to update my schema and seed my tables. #115

Open
91 tasks
stevethedev opened this issue Jan 31, 2018 · 0 comments
Assignees
Milestone

Comments

@stevethedev
Copy link
Owner

stevethedev commented Jan 31, 2018

Description

When I am working within Regent, I should be able to write migration scripts to alter the schema of my database. Within this model, I should be able to perform all of the schema manipulations and table seeding necessary to create versioned databases. When migrations are performed, those migrations should be tracked inside the database so that the system is aware of what transformations and seeds have already been completed.

  • Create a Column Schema class
    • after(<name>) inserts the current column after the column <name>
    • autoIncrement() sets the current column to be an auto-incrementing field
    • charset(<char>) sets the current column to the <char> charset
    • collation(<coll>) sets the current column to use <coll> collation
    • comment(<text>) sets the current column to have the comment <comment>
    • default(<value>) sets the current column to use the <value> default value
    • first() moves the column to the first column in the table
    • nullable(<value = true>) allows or disallows the column to hold null values
    • storedAs(<expression>) stores composite columns
    • unsigned() sets numerical columns to be unsigned
    • useCurrent() sets date columns to be current dates
    • virtualAs(<expression>) sets the virtual column in MySQL
    • references(<column>, <table>, <onDelete>) sets foreign-key constraints
  • Create a Table Schema class
    • set(<setting>, <value>) sets a configuration setting
    • get(<setting>) gets a configuration setting
    • has(<setting>) checks whether a configuration setting exists
    • temporary() sets the table as being temporary
    • bigIncrement(<name>) creates a big-integer incrementing field
    • bigInteger(<name>) creates a big-integer field
    • binary(<name>) creates a BLOB field
    • boolean(<name>) creates a boolean field
    • char(<name>, <size>) creates a character field
    • date(<name>) creates a date field
    • dateTime(<name>) creates a date-time field
    • dateTimeTz(<name>) creates a date-time field with timezone
    • decimal(<name>, <precision>, <scale>) creates a decimal field
    • double(<name>, <precision>, <scale>) creates a double-precision field
    • enum(<name>, [ ... <values>]) creates an enumerated field
    • float(<name>, <precision>, <scale>) creates a float field
    • geometry(<name>) creates a geometry field
    • geometryCollection(<name>) creates a geometry collection field
    • increments(<name>) creates an auto-increment column
    • integer(<name>) creates an integer field
    • ipAddress(<name>) creates an IP Address field
    • json(<name>) creates a JSON field
    • jsonb(<name>) creates a JSONB field
    • lineString(<name>) creates a linestring field
    • longText(<name>) creates a longtext field
    • macAddress(<name>) creates a mac address field
    • mediumIncrement(<name>) creates a medium-size integer auto-incrementing field
    • mediumInteger(<name>) creates a medium-sized integer field
    • mediumText(<name>) creates a mediumtext field
    • morphs(<name>) creates UINT <name_id> and VARCHAR <name_type> fields
    • multilineString(<name>) creates multilinestring field
    • multiPoint(<name>) creates multipoint field
    • multiPolygon(<name>) creates multipolygon field
    • nullableMorphs(<name>) creates nullable version of morphs()
    • point(<name>) creates point field
    • polygon(<name>) creates a polygon field
    • smallIncrements(<name>) creates a small-integer autoincrementing field
    • smallInteger(<name>) creates a small-integer field
    • softDeletes() creates a "deleted_at" nullable timestamp field
    • softDeletesTz() creates a "deleted_at" nullable timestamp field with timezone
    • string(<name>, [<size>]) creates a varchar field of length
    • text(<name>) creates a text field
    • time(<name>) creates a time field
    • timeTz(<name>) creates a time field with timezone
    • timestamp(<name>) creates a timestamp field
    • timestampTz(<name>) creates a timestamp field with timezone
    • timestamps() creates the "created_at" and "updated_at" timestamp fields
    • timestampsTz() creates the "created_at" and "updated_at" timestamp fields with timezones
    • tinyIncrement(<name>) creates a tiny-int auto-incrementer
    • tinyInteger(<name>) creates a tiny-integer
    • unsignedBigInteger(<name>) creates an unsigned bigint field
    • unsginedDecimal(<name>) creates an unsigned decimal field
    • unsignedInteger(<name>) creates an unsigned integer field
    • unsignedMediumInteger(<name>) creates an unsigned medium integer field
    • unsignedSmallInteger(<name>) creates an unsigned small integer field
    • unsignedTinyInteger(<name>) creates an unsigned tiny integer field
    • uuid(<name>) creates a UUID field
    • year(<name>) creates a year field
  • Create a Database Schema class
    • create(<name>, (<tableSchema>) => { /* do things */ }) initialize a table blueprint
    • hasTable(<name>) check if a table exists
    • hasColumn(<table>, <column>) check if a table has a column
    • rename(<old>, <new>) rename a table
    • drop(<table>) drop a table
    • dropIfExists(<table>) drop a table if it exists
    • table(<name>) get a table schema
    • setForeignKeyConstraints(<boolean>) enable/disable foreign key constraints
    • static connection(<dbName>) use a specific database schema
  • Create an interface for migrations to create a database schema
    • The interface should be able to initialize a schema with a default database
    • The interface should be able to initialize a schema with a specific database
    • The interface should be simple enough to be exported from a module file
  • I should be able to generate a migration file using the Regent CLI
    • The migration should be able to run a setup
    • The migration should be able to run a rollback
    • The migration should store the setup/rollback information inside of a migrations database table to track which migrations have been done
@stevethedev stevethedev self-assigned this Jan 31, 2018
@stevethedev stevethedev added this to the Regent v1.1.0 milestone Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant