Class: DatabaseSchemaOwnership::Parser::SqlParser

Inherits:
DatabaseSchemaOwnership::Parser show all
Defined in:
lib/database_schema_ownership/parser/sql_parser.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from DatabaseSchemaOwnership::Parser

#schema_path

Instance Method Summary collapse

Methods inherited from DatabaseSchemaOwnership::Parser

for, #initialize, #parse, #schema

Constructor Details

This class inherits a constructor from DatabaseSchemaOwnership::Parser

Instance Method Details

#rulesObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/database_schema_ownership/parser/sql_parser.rb', line 6

def rules
  [
    # ActiveRecord 8
    /(CREATE TABLE IF NOT EXISTS "([^"]*)"[^;]*;)/m,
    /(CREATE INDEX .* ON "([^"]*)"[^;]*;)/,

    # early versions
    /(CREATE TABLE (\S+) \([^;]*;)/m,
    /(CREATE INDEX \S+ ON (\S+) USING [^;]*;)/,
    /(CREATE UNIQUE INDEX \S+ ON (\S+) USING [^;]*;)/,
    /(ALTER TABLE ONLY (\S+)[^;]*;)/m
  ]
end