Skip to content

Commit

Permalink
New commands data generator (#5331)
Browse files Browse the repository at this point in the history
* Initial commit

* Added extra columns

* Initial commit

* Added column in help

* Added amount of rows

* Implemented query setup

* Added identity insert checks

* Corrected truncate part
Fixed setting of nex identity
Fixed error messages

* Fixed help

* Changed output to $null

* Initial commit

* Changed example
Added foreign key hierarchy query

* Changed help

* Fixed value genration
Added checks for supported data types
Added checks for supported masking types and sub types

* Copied file to different directory

* Initial commit

* Added format parameter
Added Symbol parameter
Added examples
Changed location of files
Fixed messages
Added support for all bogus types and sub types

* Revert "Added format parameter"

This reverts commit 221b17c.

* Added parameter Format
Added parameter Symbol
Added examples
Fixed messages
Added support for bogus types and sub types

* Disabled foreign key for now
Added unique index support
Removed unneccesary converions

* Moved function to public folder

* Fixed variable bug
Added random bytes

* Fixed selection of randomizer type

* Initial commit

* Added date of birth to person type

* Fixed address type

* Person is not a function but a property

* Added help
Added comments

* Renamed file

* Changed variable to handle arrays

* Initial commit

* Added example

* Added try/catch block

* Added support for piping
Added try/catch block

* Added example
Fixed piping

* Typo in help

* Added help for pipeline parameter

* Added help

* Initial commit

* Fixed bug only returning one row

* Removed dll
Fixed template retrieval

* Added support for sql data types

* Added hasuniqueindex

* Removed examples
Added supported data types
Fixed column value NULL
Implemented Get-DbaRandomizedValue

* Removed legend display

* Added check for loaded types

* Changed parameter to use user assigned value too

* Fixed unique value generation

* Removed commented code

* Added try/catch

* Formatted code

* Removed redundant file

* Removed debug stuff

* Fixed creation of faker object

* Initial commit

* Moved file

* Added check for found databases

* Removed redundant check
Code formatiing

* Removed debug message

* Fixed column data type in test

* Formatted code

* Removed parameter

* Initial commit

* Removed parameter

* Fixed test
  • Loading branch information
sanderstad authored and potatoqualitee committed Apr 3, 2019
1 parent 0c9a0b7 commit 39dc285
Show file tree
Hide file tree
Showing 16 changed files with 2,254 additions and 0 deletions.
57 changes: 57 additions & 0 deletions bin/datageneration/ForeignKeysHierarchy.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
WITH fk_tables
AS ( SELECT s1.name AS from_schema,
o1.name AS from_table,
s2.name AS to_schema,
o2.name AS to_table
FROM sys.foreign_keys fk
INNER JOIN sys.objects o1
ON fk.parent_object_id = o1.object_id
INNER JOIN sys.schemas s1
ON o1.schema_id = s1.schema_id
INNER JOIN sys.objects o2
ON fk.referenced_object_id = o2.object_id
INNER JOIN sys.schemas s2
ON o2.schema_id = s2.schema_id
/*For the purposes of finding dependency hierarchy
we're not worried about self-referencing tables*/
WHERE NOT (
s1.name = s2.name
AND o1.name = o2.name
)),
ordered_tables
AS ( SELECT s.name AS schemaName,
t.name AS tableName,
0 AS Level
FROM ( SELECT * FROM sys.tables WHERE name <> 'sysdiagrams' ) t
INNER JOIN sys.schemas s
ON t.schema_id = s.schema_id
LEFT OUTER JOIN fk_tables fk
ON s.name = fk.from_schema
AND t.name = fk.from_table
WHERE fk.from_schema IS NULL
UNION ALL
SELECT fk.from_schema,
fk.from_table,
ot.Level + 1
FROM fk_tables fk
INNER JOIN ordered_tables ot
ON fk.to_schema = ot.schemaName
AND fk.to_table = ot.tableName )
SELECT DISTINCT
ot.schemaName,
ot.tableName,
ot.Level
FROM ordered_tables ot
INNER JOIN (
SELECT schemaName,
tableName,
MAX(Level) maxLevel
FROM ordered_tables
GROUP BY schemaName,
tableName
) mx
ON ot.schemaName = mx.schemaName
AND ot.tableName = mx.tableName
AND mx.maxLevel = ot.Level
ORDER BY ot.Level,
ot.tableName;
Binary file added bin/randomizer/Bogus.dll
Binary file not shown.
264 changes: 264 additions & 0 deletions bin/randomizer/en.randomizertypes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
Type,SubType
Address,BuildingNumber
Address,CardinalDirection
Address,City
Address,CityPrefix
Address,CitySuffix
Address,Country
Address,CountryCode
Address,County
Address,Direction
Address,FullAddress
Address,Latitude
Address,Longitude
Address,OrdinalDirection
Address,SecondaryAddress
Address,State
Address,StateAbbr
Address,StreetAddress
Address,StreetName
Address,StreetSuffix
Address,ZipCode
Commerce,Categories
Commerce,Color
Commerce,Department
Commerce,Price
Commerce,Product
Commerce,ProductAdjective
Commerce,ProductMaterial
Commerce,ProductName
Company,Bs
Company,CatchPhrase
Company,CompanyName
Company,CompanySuffix
Database,Collation
Database,Column
Database,Engine
Database,Type
Date,Between
Date,BetweenOffset
Date,Future
Date,FutureOffset
Date,Month
Date,Past
Date,PastOffset
Date,Recent
Date,RecentOffset
Date,Soon
Date,SoonOffset
Date,Timespan
Date,Weekday
Date,Random
Finance,Account
Finance,AccountName
Finance,Amount
Finance,Bic
Finance,BitcoinAddress
Finance,CreditCardCvv
Finance,CreditCardNumber
Finance,Currency
Finance,EthereumAddress
Finance,Iban
Finance,RoutingNumber
Finance,TransactionType
Hacker,Abbreviation
Hacker,Adjective
Hacker,IngVerb
Hacker,Noun
Hacker,Phrase
Hacker,Verb
Hacker,Random
Hashids,Decode
Hashids,DecodeHex
Hashids,DecodeLong
Hashids,Decrypt
Hashids,DecryptHex
Hashids,Encode
Hashids,EncodeHex
Hashids,EncodeLong
Hashids,Encrypt
Hashids,EncryptHex
Image,Abstract
Image,Animals
Image,Business
Image,Cats
Image,City
Image,DataUri
Image,Fashion
Image,Food
Image,Image
Image,Nature
Image,Nightlife
Image,People
Image,Sports
Image,Technics
Image,Transport
Image,Random
IndexFaker,CompareTo
IndexFaker,GetTypeCode
IndexFaker,ToBoolean
IndexFaker,ToByte
IndexFaker,ToChar
IndexFaker,ToDateTime
IndexFaker,ToDecimal
IndexFaker,ToDouble
IndexFaker,ToInt16
IndexFaker,ToInt32
IndexFaker,ToInt64
IndexFaker,ToSByte
IndexFaker,ToSingle
IndexFaker,ToType
IndexFaker,ToUInt16
IndexFaker,ToUInt32
IndexFaker,ToUInt64
IndexGlobal,CompareTo
IndexGlobal,GetTypeCode
IndexGlobal,ToBoolean
IndexGlobal,ToByte
IndexGlobal,ToChar
IndexGlobal,ToDateTime
IndexGlobal,ToDecimal
IndexGlobal,ToDouble
IndexGlobal,ToInt16
IndexGlobal,ToInt32
IndexGlobal,ToInt64
IndexGlobal,ToSByte
IndexGlobal,ToSingle
IndexGlobal,ToType
IndexGlobal,ToUInt16
IndexGlobal,ToUInt32
IndexGlobal,ToUInt64
IndexVariable,CompareTo
IndexVariable,GetTypeCode
IndexVariable,ToBoolean
IndexVariable,ToByte
IndexVariable,ToChar
IndexVariable,ToDateTime
IndexVariable,ToDecimal
IndexVariable,ToDouble
IndexVariable,ToInt16
IndexVariable,ToInt32
IndexVariable,ToInt64
IndexVariable,ToSByte
IndexVariable,ToSingle
IndexVariable,ToType
IndexVariable,ToUInt16
IndexVariable,ToUInt32
IndexVariable,ToUInt64
Internet,Avatar
Internet,Color
Internet,DomainName
Internet,DomainSuffix
Internet,DomainWord
Internet,Email
Internet,ExampleEmail
Internet,Ip
Internet,Ipv6
Internet,Mac
Internet,Password
Internet,Protocol
Internet,Url
Internet,UrlWithPath
Internet,UserAgent
Internet,UserName
Lorem,Letter
Lorem,Lines
Lorem,Paragraph
Lorem,Paragraphs
Lorem,Sentence
Lorem,Sentences
Lorem,Slug
Lorem,Text
Lorem,Word
Lorem,Words
Lorem,Random
Name,FindName
Name,FirstName
Name,FullName
Name,JobArea
Name,JobDescriptor
Name,JobTitle
Name,JobType
Name,LastName
Name,Prefix
Name,Suffix
Name,HasFirstNameList
Name,Random
Name,SupportsGenderFirstNames
Name,SupportsGenderLastNames
Name,SupportsGenderPrefixes
Person,Address
Person,Avatar
Person,Company
Person,Context
Person,DateOfBirth
Person,Email
Person,FirstName
Person,FullName
Person,Gender
Person,LastName
Person,Phone
Person,Random
Person,UserName
Person,Website
Phone,PhoneNumber
Phone,PhoneNumberFormat
Phone,Random
Random,AlphaNumeric
Random,Bool
Random,Byte
Random,Bytes
Random,Char
Random,Chars
Random,ClampString
Random,CollectionItem
Random,Decimal
Random,Digits
Random,Double
Random,Enum
Random,Even
Random,Float
Random,Guid
Random,Hash
Random,Hexadecimal
Random,Int
Random,ListItem
Random,ListItems
Random,Long
Random,Number
Random,Odd
Random,RandomLocale
Random,Replace
Random,ReplaceNumbers
Random,ReplaceSymbols
Random,SByte
Random,Short
Random,Shuffle
Random,String
Random,String2
Random,UInt
Random,ULong
Random,UShort
Random,Uuid
Random,WeightedRandom
Random,Word
Random,Words
Random,WordsArray
Rant,Review
Rant,Reviews
Rant,Random
System,AndroidId
System,ApplePushToken
System,BlackBerryPin
System,CommonFileExt
System,CommonFileName
System,CommonFileType
System,DirectoryPath
System,Exception
System,FileExt
System,FileName
System,FilePath
System,FileType
System,MimeType
System,Semver
System,Version
40 changes: 40 additions & 0 deletions bin/randomizer/templates/PersonalData.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"Name": "Personal Data",
"Columns": [
{
"Name": "FirstName",
"Type": "Name",
"SubType": "FirstName"
},
{
"Name": "LastName",
"Type": "Name",
"SubType": "LastName"
},
{
"Name": "Address",
"Type": "Address",
"SubType": "StreetAddress"
},
{
"Name": "Zipcode",
"Type": "Address",
"SubType": "Zipcode"
},
{
"Name": "City",
"Type": "Address",
"SubType": "City"
},
{
"Name": "Country",
"Type": "Address",
"SubType": "Country"
},
{
"Name": "Birthday",
"Type": "Person",
"SubType": "DateOfBirth"
}
]
}
Loading

0 comments on commit 39dc285

Please sign in to comment.